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?

Input

The first line of the input contains three integers nb 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.

Output

Print one integer — the number of times Kolya will have to empty the waste section.

Examples
input
2 7 10
5 6
output
1
input
1 5 10
7
output
0
input
3 10 10
5 7 7
output
1
input
1 1 1
1
output
0
Note

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的更多相关文章

  1. 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 ...

  2. AIM Tech Round 3 (Div. 2)

    #include <iostream> using namespace std; ]; int main() { int n, b, d; cin >> n >> ...

  3. AIM Tech Round 3 (Div. 2) A B C D

    虽然打的时候是深夜但是状态比较好 但还是犯了好多错误..加分场愣是打成了降分场 ABC都比较水 一会敲完去看D 很快的就想出了求0和1个数的办法 然后一直wa在第四组..快结束的时候B因为低级错误被h ...

  4. AIM Tech Round 3 (Div. 2) B

    Description Vasya takes part in the orienteering competition. There are n checkpoints located along ...

  5. 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 ...

  6. AIM Tech Round 3 (Div. 2) B 数学+贪心

    http://codeforces.com/contest/709 题目大意:给一个一维的坐标轴,上面有n个点,我们刚开始在位置a,问,从a点开始走,走n-1个点所需要的最小路程. 思路:我们知道,如 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Java: xml转换

    java对于xml的转换有很多种,比较有名的有:DOM, DOM4J, JDOM, SAX.这里要介绍的是javax.xml包的对xml文件的转换.相比于前面几种是最简单的. 直接上代码: Stude ...

  2. poj: 1207

    好吧这题竟然还有先大后小的可能,能不这么恶心下吗.. #include <iostream> #include <stdio.h> #include <string.h& ...

  3. Android studio删除工程项目,androidstudio

    本新手最近学Android都是用的eclipse.其实个人觉得eclipse不错,可能接触Android不久,倒也不觉得它慢还是怎样.对于Google的Android studio也是早有耳闻,前两天 ...

  4. 封装mysqli类

    类: <?phpheader('content-type:text/html;charset=utf-8');/*掌握满足单例模式的必要条件(1)私有的构造方法-为了防止在类外使用new关键字实 ...

  5. android waiting for debugger

    在Studio开发环境中,使用真机开发经常会出现waiting for debugger,卡死不动了,让人很崩溃啊,现在我就总结下几种解决方法,希望能帮到出现同样情况的朋友! 问题出现及解决办法: 多 ...

  6. Creating Directives that Communicate

    <my-tabs> <my-pane title="Hello"> <h4>Hello</h4> <p>Lorem ip ...

  7. canvas基本画图

    <img src="img/lamp.gif" id="lamp"/> <img src="img/eg_tulip.jpg&quo ...

  8. drds 广播表的创建以及使用

    创建表 , 关键词 : BROADCAST CREATE TABLE `financial_product_yjw` ( `ID` int(10) unsigned NOT NULL AUTO_INC ...

  9. 6. 星际争霸之php设计模式--建造器模式

    题记==============================================================================本php设计模式专辑来源于博客(jymo ...

  10. 锋利的JQuery(二)

    释义: DOM:Document Object Model 文档对象模型 DOM操作细分:DOM Core .HTML-DOM.CSS-DOM text():对HTML文档和XML文档都有效