Submission #4179

#TimeUsernameProblemLanguageResultExecution timeMemory
4179hsswillKing of penalty (kriii1_K)C++98
0 / 1
0 ms1476 KiB
#include<stdio.h> #include<algorithm> using std::sort; int data[100011]; int main(void) { int a, i, sum, n, t = 0, result; scanf("%d %d",&a,&n); for(i = 0; i < n; i++) scanf("%d",&data[i]); sort( data, data+n ); sum = 0; for(i = 0; i < n; i++) { sum += data[i]; if( sum >= a ) break; } result = i; sum = t = 0; for(i = result-1; i >= 0; i--) { sum += data[i]; t += sum; } printf("%d %d",result,t+a); }
#Verdict Execution timeMemoryGrader output
Fetching results...