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 ...
随机推荐
- 01分数规划POJ2976(简单模板题)
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7276 Accepted: 2523 De ...
- Java基础(35):装箱与拆箱---Java 中基本类型和包装类之间的转换(Wrapper类)
基本类型和包装类之间经常需要互相转换,以 Integer 为例(其他几个包装类的操作雷同哦): 在 JDK1.5 引入自动装箱和拆箱的机制后,包装类和基本类型之间的转换就更加轻松便利了. 那什么是装箱 ...
- 安装Git
因为我的开发环境是Windows,那么在windows下安装Git就简单很多了.首先在,从http://msysgit.github.io/下载Git的安装程序,然后按默认选项安装即可. 安装成功之后 ...
- HDU 3308 LCIS(线段树)
Problem Description Given n integers.You have two operations:U A B: replace the Ath number by B. (in ...
- JFreeChart在制作折线图
JFreeChart在制作折线图的时候可以使用两种不同的方式 package Line; import java.awt.Color; import java.awt.Font; import org ...
- libSVM的数据格式
首先介绍一下 libSVM的数据格式 Label 1:value 2:value -. Label:是类别的标识,比如上节train.model中提到的1 -1,你可以自己随意定,比如-10,0,15 ...
- Python for z/OS
Install pythondev Install DB2 or server driver package easy_install ibm_db Get license file from tor ...
- sp_executesql的执行计划会被重用(转载)
前一段时间,给一位朋友公司做咨询,看到他们的很多的存储过程都存在动态sql语句执行,sp_executesql,即使在没有动态表名,动态字段名的情况下仍然使用sp_executesql,这个做法是不太 ...
- Sed文本替换一例
使用 Sed 完成文本替换操作任务是非常合适的. 现在, 假设我要将一个原有 Java 项目中的一些包及下面的类移到另一个项目中复用. Project javastudy: Packages: alg ...
- JavaEE基础(二十五)/多线程、GUI
1.多线程(单例设计模式) 单例设计模式:保证类在内存中只有一个对象. 如何保证类在内存中只有一个对象呢? (1)控制类的创建,不让其他类来创建本类的对象.private (2)在本类中定义一个本类的 ...