# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3669 | qja0950 | King of penalty (kriii1_K) | C++98 | 24 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;
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", ×[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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |