AmazonOA #378
Get Success Value (Fungible :)
估计简单可在线判题
For each query k, find the total number of viewers in the k regions with the most viewers. Regions with equal viewer counts are counted separately; queries are independent and are answered in input order.
输入格式
The first line contains n q, the second line contains n viewer counts, and the third line contains q queries. Original bounds: 1≤n,q≤100000, 1≤viewers≤10^9, 1≤k≤n. This site outputs exact integers, not limited by the original int return signature.
输出格式
Output q exact integers in query order, separated by whitespace.
样例 1
输入:
3 3
5 6 10
1 2 3
输出:
10 16 21
样例 2
输入:
3 2
7 7 1
2 1
输出:
14 7
样例 3
输入:
1 2
1
1 1
输出:
1 1
样例说明
The outputs of the three public examples are, in order: 10 16 21; 14 7; 1 1. Verified by independent enumeration or direct simulation.