LOWSUM-getting wrong answer

My logic is since in the given constraints qi ranges form 1 to 10000 that is we are not going to ask the minimum element 100001 or more…so we can just sort the given input array and take the sum of just 100 values from first array with the 100 element of second array and store it in vector effectively I am just caluclating the 10000 sums and then answering the queries in o(1) time.
Here is my code

How can you say that the first 100 elements of both array will only contribute in result.
k=10000
a[]={100,200,300…}
b[]={1,1,…}
You may see this CodeChef: Practical coding for everyone It is based on priority queue

2 Likes

@sebastian Thanks…it really helped