All Tracks Data Structures Advanced Data Structures Segment Trees Problem

Alpha and His array
Tag(s):

Easy, Multiset, Segment Trees

Problem
Editorial
Analytics

Rohit has given array A and array D with n elements.

On ith day,

Rohit performs an operation for each 1 ≤ j ≤ i 

                   A[ j ] = A[ j ] - D[ i ]     ,if A[ j ] >= D[ i ]            (Decreased Aj by Di)

                   A[ j ] = 0                       ,otherwise                    (Decreased Aj by Aj)

 

Now for each day i (1<=i<=N) you have to tell the total value decreased by Rohit

Input Format:

The first line of input will contain single integer N.

Next line will contain N integers, denoting array A

Next line is left blank.

Next line will contain N integers, denoting array D

Output Format:

Output N integer separated by space which denotes Total value decreased by Rohit on ith day. 

Constraints :

$$ 1 \le N \le 100000 $$

$$ 1 \le Ai \le 1000000000 $$

$$ 1 \le Di \le 1000000000 $$

 

SAMPLE INPUT
5
3 5 6 5 2 

3 9 1 1 7 
SAMPLE OUTPUT
3 5 1 2 10 
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

通知
View All Notifications

?