# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3506 | imsifile | King of penalty (kriii1_K) | C++98 | 24 ms | 1956 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;
long long p, n, ba[111111], cnt, hh, dap, i;
int main(){
scanf("%lld%lld", &p,&n);
for(i=0; i<n; i++)scanf("%lld", &ba[i]);
sort(ba, ba+n);
for(i=0; i<n; i++){
if(hh+ba[i]>=p)break;
cnt++, hh+=ba[i];
}
hh=p-1;
for(i=0; i<cnt; i++)dap+=hh, hh-=ba[i];
printf("%lld %lld", cnt, dap);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |