All Tracks Algorithms Searching Binary Search Problem

Bishu and Soldiers
/

Binary Search, Brute Force, Very-Easy, Very-Easy

Problem
Editorial
Analytics

Bishu went to fight for Coding Club. There were N soldiers with various powers. There will be Q rounds to fight and in each round Bishu's power will be varied. With power M, Bishu can kill all the soldiers whose power is less than or equal to M(<=M). After each round, All the soldiers who are dead in previous round will reborn.Such that in each round there will be N soldiers to fight. As Bishu is weak in mathematics, help him to count the number of soldiers that he can kill in each round and total sum of their powers.

1<=N<=10000

1<=power of each soldier<=100

1<=Q<=10000

1<=power of bishu<=100

SAMPLE INPUT
7
1 2 3 4 5 6 7
3
3
10
2
SAMPLE OUTPUT
3 6
7 28
2 3
Explanation

In first round bhishu power is 3

So there are 3 soldiers whose power is <=3 and the sum of their power is 1+2+3=6

therefore ans= 3 6

same for the next round

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

Initializing Code Editor...
Notifications
View All Notifications

?