codeforces AIM Tech Round3
来源:互联网 发布:吴闲云水浒知乎 编辑:程序博客网 时间:2024/05/22 03:02
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 105 6
1
1 5 107
0
3 10 105 7 7
1
1 1 11
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.
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;int main(){int n,b,d,tot=0,i,j,k,ans=0;cin>>n>>b>>d;for(i=1;i<=n;i++){int x;scanf("%d",&x);if(x>b)continue;tot+=x;if(tot>d){ans++;tot=0;}} cout<<ans;}
- codeforces AIM Tech Round3
- codeforces aim teach round3 div2
- codeforces AIM Tech Round
- Codeforces AIM Tech Round (Div. 1) ABD
- Codeforces AIM Tech Round (Div. 2) 题解
- 【codeforces】AIM Tech Round 3 (Div. 2)
- codeforces AIM Tech Round 3 (Div. 2)
- Codeforces AIM Tech Round (Div. 2) A. Save Luke
- Codeforces AIM Tech Round (Div. 2) B. Making a String
- Codeforces AIM Tech Round (Div. 2)解题报告
- Codeforces AIM-TECH round div2 624AB 623ABC
- Codeforces AIM Tech Round (Div. 2) A. Save Luke
- codeforces AIM Tech Round 3 (Div. 2) B. Checkpoints
- CodeForces AIM Tech Round 3 (Div. 2) D
- codeforces AIM Tech Round 3 (Div. 2) (A~D)
- Codeforces Aim Tech Round 3 (Div.2 )B.Checkpoints【思维】
- codeforces AIM Tech Round 3 (Div. 2) B. Checkpoints
- Codeforces AIM Tech Round 3 (Div. 2)(A-D 未完)
- iOS开发学习之Quartz2D绘图
- Linux进程之task_struct结构体
- 简单的学生管理系统
- ToStringBuilder学习(四):readResolve()方法与序列化
- poj 2485
- codeforces AIM Tech Round3
- leetcode 160. Intersection of Two Linked Lists
- 大数据框架 Hadoop 和 Spark 的异同
- 根据Dictionary KEY 自动生成属性
- 渗透测试 2 of 9
- Nosql Mongodb 并发控制之乐观锁
- NYOJ 975 关于521
- 内存结构分析学习笔记
- AppCan_4 IDE 开发流程之新建项目同步到线上