Submission #3669

#TimeUsernameProblemLanguageResultExecution timeMemory
3669qja0950King of penalty (kriii1_K)C++98
1 / 1
24 ms1476 KiB
#include <stdio.h> #include <algorithm> using namespace std; int p, n; long long int 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 %lld", i-1, ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...