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.
You may see this https://www.codechef.com/viewsolution/33234982 It is based on priority queue

1 Like

@sebastian Thanks…it really helped