1002 Coin Washing Machine
Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Problem Description Nowadays the living conditions of college students are getting better, recently, a university in Inner Mongolia has acquired a coin washing machine in every dormitory building.
Xiao Ming as a regular training in the ACM team, very Busy (Lan) Lu (Duo), of course, very happy to throw clothes to the washing machine solution. According to the number of clothes to be washed, the coin washing machine needs to put 2-4 coins each time.
Xiao Ming is a very easy to sweat boys, summer is coming, every day to bathe, so there are a large number of clothes need to wash.
Xiaoming is making the coin washing machine plan: When the amount of clothing is more than equals A and less than B, he would immediately wash the washing machine and put in 2 coins, and when the stocking quantity was greater than B and less than C, he would take it all to wash the washing machine and put in 3 coins. When the stocking quantity is greater than or equal to C, he will immediately take all the washing machine and put 4 coins. See examples for other details.
Now know, xiaoming past n days to change the number of clothes per day V, you need help to calculate the past time xiaoming spent washing clothes altogether how much money.
Input input contains multiple sets of test data.
The first row of each set of data is 4 positive integers n (1<=n<=10000), A, B, C (1<=A<B<C<=300), as described in the topic.
The second row of each set of data contains n positive integers, in order, the number of clothes produced in the past n days per day V (1<=v<=1000).
Output an integer for each set of data, indicating how much money the laundry service spent in the past n days.
One row for each set of outputs.
Sample Input
3 2 4 6 2 2 1
Sample Output
4
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int v,a,b,c,n,i,s=0,sum;
while (~SCANF ("%d%d%d%d", &n,&a,&b,&c))
{
s=0;
sum=0;
For (i=0 i<n; i++)
{
scanf ("%d", &v);
Sum+=v;
if (sum>=c)
{
s+=4;
sum=0;
}
else if (sum>=b)
{
s+=3;
sum=0;
}
else if (sum>=a)
{
s+=2;
Sum=0
}
}
printf ("%d\n", s);
}
return 0;
}
Always looking at once space in a daze, those who say not separate friends, turn around, strangers. Familiar, quiet, quiet, left, left, unfamiliar, unfamiliar, disappeared, disappeared, strangers.