Submission #3668

#TimeUsernameProblemLanguageResultExecution timeMemory
3668qja0950King of penalty (kriii1_K)C++98
0 / 1
16 ms1476 KiB
#include <stdio.h> #include <algorithm> using namespace std; int p, n, ans; int times[100001]; int main() { scanf("%d %d", &p, &n); p--; int i; for(i=1; i<=n; i++) scanf("%d", &times[i]); sort(times+1, times+n+1); for(i=1; i<=n; i++) { if(p-times[i]>=0) { ans+=p; p-=times[i]; }else break; } printf("%d %d", i-1, ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...