I want to know in which case my code is failing.
Below is the link to the question:
Below is the code:
#include<iostream>
#include<cstdio>
#include<algorithm>
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
FAST_IO
unsigned long int N,Q,K,sum=0;
cin>>N;
unsigned long int A[N],A_K[N];
for(unsigned long int i=0;i<N;i++)
cin>>A[i];
sort(A,A+N);
for(unsigned long int j=0;j<N;j++)
{
sum=sum+A[j];
A_K[j]=sum;
}
cin>>Q;
for(unsigned long int i=0;i<Q;i++)
{
cin>>K;
cout<<A_K[N-K-1]<<"\n";
}
return 0;
}