# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3412 | movie_jo | 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 x[100000];
int main(void)
{
int P, N, i, t;
long long S = 0;
scanf("%d %d", &P, &N);
for(i = 0; i < N; i++)
scanf("%d", x + i);
sort(x, x + N);
t = P - 1;
for(i = 0; i < N && t >= 0; i++)
{
if(t - x[i] >= 0)
S += t;
else
break;
t -= x[i];
}
printf("%d %lld\n", i, S);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |