codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

923B.md (2293B)


      1 Source: https://codeforces.com/problemset/problem/923/B
      2 
      3 B. Producing Snow
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day *i* he will make a pile of snow of volume *V**i* and put it in her garden.
     22 
     23 Each day, every pile will shrink a little due to melting. More precisely, when the temperature on a given day is *T**i*, each pile will reduce its volume by *T**i*. If this would reduce the volume of a pile to or below zero, it disappears forever. All snow piles are independent of each other.
     24 
     25 Note that the pile made on day *i* already loses part of its volume on the same day. In an extreme case, this may mean that there are no piles left at the end of a particular day.
     26 
     27 You are given the initial pile sizes and the temperature on each day. Determine the total volume of snow melted on each day.
     28 
     29 Input
     30 
     31 The first line contains a single integer *N* (1 ≤ *N* ≤ 105) — the number of days.
     32 
     33 The second line contains *N* integers *V*1, *V*2, ..., *V**N* (0 ≤ *V**i* ≤ 109), where *V**i* is the initial size of a snow pile made on the day *i*.
     34 
     35 The third line contains *N* integers *T*1, *T*2, ..., *T**N* (0 ≤ *T**i* ≤ 109), where *T**i* is the temperature on the day *i*.
     36 
     37 Output
     38 
     39 Output a single line with *N* integers, where the *i*-th integer represents the total volume of snow melted on day *i*.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 3  
     47 10 10 5  
     48 5 7 2
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 5 12 4
     55 ```
     56 
     57 Input
     58 
     59 ```
     60 5  
     61 30 25 20 15 10  
     62 9 10 12 4 13
     63 ```
     64 
     65 Output
     66 
     67 ```
     68 9 20 35 11 25
     69 ```
     70 
     71 Note
     72 
     73 In the first sample, Bob first makes a snow pile of volume 10, which melts to the size of 5 on the same day. On the second day, he makes another pile of size 10. Since it is a bit warmer than the day before, the first pile disappears completely while the second pile shrinks to 3. At the end of the second day, he has only a single pile of size 3. On the third day he makes a smaller pile than usual, but as the temperature dropped too, both piles survive till the end of the day.