A. Juicer
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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 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.
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
个橘子,橘子有高度,高度大于
思路:直接加即可,当 sum>d 的时候清空 sum ,答案加一。
ac代码:
/* ***********************************************
Author : AnICoo1
Created Time : 2016-08-25-16.31 Thursday
File Name : D:\MyCode\2016-8月\2016-8-25.cpp
LANGUAGE : C++
Copyright 2016 clh All Rights Reserved
************************************************ */
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#define LL long long
#define ll __int64
#define mem(x,y) memset(x,(y),sizeof(x))
#define PI acos(-1)
#define gn (sqrt(5.0)+1)/2
#define eps 1e-8
using namespace std;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
double dpow(double a,ll b){double ans=1.0;while(b){if(b%2)ans=ans*a;a=a*a;b/=2;}return ans;}
const ll INF=1e9+10;
const int MAXN=1e6+10;
const int MOD=1e9+7;
//head
int main()
{
int n,b,d;cin>>n>>b>>d;
int ans=0;
int sum=0;
for(int i=1;i<=n;i++)
{
int a;cin>>a;
if(a<=b)
{
sum+=a;
if(sum>d)
sum=0,ans++;
}
}
printf("%d\n",ans);
return 0;
}