| Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Ibrahim Mesecan.
 
 
 Paint Buckets  In a competition for students, students are asked to collect 
some paint and fill them into buckets.
Buckets are on a rail system and they can take different amount 
of paints. On the rail system they wait certain time and 
then, they leave. 
The gathered paint at that time can be poured into the active 
bucket. If it's full, the half of the extra paint
can be poured to the next and the other half of the extra paint 
can be poured to the previous buckets.
If they are also full (or they overflood), the gathered extra 
paint is wasted out. Question: Write a program that is going to first read bucket sizes and 
then collected paint amounts. 
The program is going to find out the amount of paint 
collected by this team.
 Note:  The first bucket doesn't have the 
previous and the last bucket doen't have the next. 
Thus, if the first one overfloods to the previous, the 
extra paint is wasted.
 Input specification  You will be first given an integer number (n) which is 
number of buckets where 0 ≤ n  ≤ 15000.
Then, you will be given n bucket size in the following 
line. The buckets can have sizes
between 1 and 20litters. The following line will have 
n floating point numbers, the amount of 
paint gathered by students which may vary between 0 and 20.
 Output specification  Show a floating point number (with 3 decimal place precision), 
the amount of paint gathered bu students.
 
 
| Sample Input I 
 
  6 5    14  14     9    16     17
 7   7.5  20    13   4.5     19
 | Sample Input II 
 
  5 15 5  11 4 2
 14 12 5.5 12 8
 |  
| Sample Output I 
 
  65.5  | Sample Output II 
 
  37  |  Explanation: They always pour the collected paint firstly to 
the active bucket. If the bucket is full and there is extra
paint, half of the remaining paint is poured to the bucket
on the right and the other half is poured to the bucket on
the left.
 The size of first bucket is 5 liters. And the students 
have collected 7 liters. So, they pour 5 liters to the first bucket. 
Half of remaining amount (1 liter) is poured to the second 
bucket. The capacity of the second bucket is 14 liters. And 
students have collected 7.5 liters. So, they can pour all of 
it to the second bucket. The capacity of the third bucket is 
also 14 liters. And students have collected 20 liters. They 
can firstly fill the third bucket (14 liters), then half of the 
remaining amount can be poured to the second bucket and the other 
half can be poured to the fourth bucket.
Thus, the second bucket has 11.5 liters of paint. (1 liter from 
the first bucket, 7.5 liters from the second bucket and 3 
liters from the third bucket.)
   Для отправки решений необходимо выполнить вход.
 
 
 |