All Tracks Data Structures Advanced Data Structures Segment Trees Problem

Little Deepu and Array
Tag(s):

Algorithms, Easy, Tree

Problem
Editorial
Analytics

Little Deepu loves positive things in life, positive girlfriends, positive marks. He's, in general a lover of positive things, so for obvious reasons he loves an array which contains positive elements.

Anyway, Little Deepu also thinks that not every value in his so called positive array deserves to be valued so high, so he makes an operation called HIT which takes exactly one argument, i.e., HIT (X). When HIT (X) is called, it decreases the value of all the elements of the array by 1 which are greater than X.

Now, to test how positive can you stay in life, he performs M HIT operations, and after they have been done, Deepu wants you to print the final array.

Input:
First line contains N the size of array. Second lines contains N elements of array. Third line contains an integer M next M lines contains a single integer X.

Output:
Print final array after M HIT operations.

Constraints:
1<=N<=100000
1<=A[i]<=1000000000
1<=M<=20000
1<=X<=1000000000

SAMPLE INPUT
5
7 8 3 2 10
4
1
3
5
7

SAMPLE OUTPUT
5 5 2 1 7
Time Limit: 5.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

This Problem was Asked in

Druva

Challenge Name

Druva Development Engineers' Challenge

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?