# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3668 | qja0950 | King of penalty (kriii1_K) | C++98 | 16 ms | 1476 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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", ×[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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |