AIM Tech Round 3 (Div. 2) A
Description
Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly greater he throws it away and continues with the next one.
The juicer has a special section to collect waste. It overflows if Kolya squeezes oranges of the total size strictly greater than d. When it happens Kolya empties the waste section (even if there are no more oranges) and continues to squeeze the juice. How many times will he have to empty the waste section?
The first line of the input contains three integers n, b and d (1 ≤ n ≤ 100 000, 1 ≤ b ≤ d ≤ 1 000 000) — the number of oranges, the maximum size of the orange that fits in the juicer and the value d, which determines the condition when the waste section should be emptied.
The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 1 000 000) — sizes of the oranges listed in the order Kolya is going to try to put them in the juicer.
Print one integer — the number of times Kolya will have to empty the waste section.
2 7 10
5 6
1
1 5 10
7
0
3 10 10
5 7 7
1
1 1 1
1
0
In the first sample, Kolya will squeeze the juice from two oranges and empty the waste section afterwards.
In the second sample, the orange won't fit in the juicer so Kolya will have no juice at all.
题意:就是给你n个水果,有台榨汁机(最多一次性只能装b大小的水果,容量是d),如果超过容量就清理一次。问你要清理几次
解法:模拟,超过大小的可以不要,相加的和超过容量的就清零,num+1
#include<bits/stdc++.h>
using namespace std;
long long a[100005],b,d;
int main()
{
int n;
long long sum=0;
long long num=0;
cin>>n>>b>>d;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(a[i]<=b)
{
sum+=a[i];
}
else
{
continue;
}
if(sum>d)
{
sum=0;
num++;
}
}
cout<<num<<endl;
return 0;
}
AIM Tech Round 3 (Div. 2) A的更多相关文章
- codeforce AIM tech Round 4 div 2 B rectangles
2017-08-25 15:32:14 writer:pprp 题目: B. Rectangles time limit per test 1 second memory limit per test ...
- AIM Tech Round 3 (Div. 2)
#include <iostream> using namespace std; ]; int main() { int n, b, d; cin >> n >> ...
- AIM Tech Round 3 (Div. 2) A B C D
虽然打的时候是深夜但是状态比较好 但还是犯了好多错误..加分场愣是打成了降分场 ABC都比较水 一会敲完去看D 很快的就想出了求0和1个数的办法 然后一直wa在第四组..快结束的时候B因为低级错误被h ...
- AIM Tech Round 3 (Div. 2) B
Description Vasya takes part in the orienteering competition. There are n checkpoints located along ...
- AIM Tech Round 3 (Div. 2) (B C D E) (codeforces 709B 709C 709D 709E)
rating又掉下去了.好不容易蓝了.... A..没读懂题,wa了好几次,明天问队友补上... B. Checkpoints 题意:一条直线上n个点x1,x2...xn,现在在位置a,求要经过任意n ...
- AIM Tech Round 3 (Div. 2) B 数学+贪心
http://codeforces.com/contest/709 题目大意:给一个一维的坐标轴,上面有n个点,我们刚开始在位置a,问,从a点开始走,走n-1个点所需要的最小路程. 思路:我们知道,如 ...
- AIM Tech Round 3 (Div. 2)D. Recover the String(贪心+字符串)
D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input standar ...
- AIM Tech Round 4 (Div. 2)ABCD
A. Diversity time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- AIM Tech Round 4 (Div. 2)(A,暴力,B,组合数,C,STL+排序)
A. Diversity time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...
随机推荐
- [原创]java WEB学习笔记74:Struts2 学习之路--自定义拦截器,struts内建的拦截器
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- << 链式重载
#include <iostream> using namespace std; class Complex { private: int a, b; public: Complex(in ...
- 父类构造函数中的this指针在子类构造对象后,这个this指针指向什么
子类的对象内存布局包括两部分:父类和子类派生部分,所以执行父类的构造函数只不过是在构造子类对象的父类部分.因此子类对象的this指针是指向子类对象自己.
- CCF真题之命令行选项
201403-3 问题描述 请你写一个命令行分析程序,用以分析给定的命令行里包含哪些选项.每个命令行由若干个字符串组成,它们之间恰好由一个空格分隔.这些字符串中的第一个为该命令行工具的名字,由小写字母 ...
- Linux下用SCP无需输入密码传输文件
在Linux环境下,两台主机之间传输文件一般使用scp命令,通常用scp命令通过ssh获取对方linux主机文件的时候都需要输入密码确认. 不过通过建立信任关系,可以实现不输入密码. 这里假设A的IP ...
- 前端单页应用SEO解决方案
在这里只会提到Google的解决方案,日后再补充百度的解决方案 我们经常使用的单页都是#!来做应用的前端路由,因为这个在多个版本浏览器上有很好的兼容性 当Google发现URL里有#!符号,Googl ...
- 四种MySQL存储引擎
前言 数据库存储引擎是数据库底层软件组织,数据库管理系统(DBMS)使用数据引擎进行创建.查询.更新和删除数据.不同的存储引擎提供不同的存储机制.索引技巧.锁定水平等功能,使用不同的存储引擎,还可以 ...
- java的web项目中使用cookie保存用户登陆信息
本文转自:http://lever0066.iteye.com/blog/1735963 最近在编写论坛系统的实现,其中就涉及到用户登陆后保持会话直到浏览器关闭,同时可以使用cookie保存登陆信息以 ...
- Linux workqueue工作原理 【转】
转自:http://blog.chinaunix.net/uid-21977330-id-3754719.html 转自:http://bgutech.blog.163.com/blog/static ...
- JavaScript,base64加密解密
直接下载吧: http://files.cnblogs.com/files/xiluhua/base64Decode.js