# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3443 | pl0892029 | 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 <cstdio>
#include <algorithm>
using namespace std;
int Problem[100000];
int main() {
int P, N;
scanf("%d %d",&P,&N);
for(int i=0;i<N;i++)
scanf("%d",Problem+i);
sort(Problem,Problem+N);
int sum = 0, idx = 0;
for(int i=0;i<N;i++) {
sum += Problem[i];
if(sum >= P)
break;
idx = i;
}
printf("%d ",idx+1); // Maximum solving problems
for(int i=idx-1;i>=0;i--)
Problem[i] += Problem[i+1];
long long panelty = 0;
for(int i=idx;i>=0;i--)
panelty += Problem[i] + P-Problem[0]-1;
printf("%lld",panelty);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |