# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3479 | zzapcoder | King of penalty (kriii1_K) | C++98 | 24 ms | 1976 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 <vector>
#include <algorithm>
int P, N;
std::vector<int> T;
bool compare(int a, int b)
{
if ( a < b )
return true;
else
return false;
}
int main()
{
scanf("%d %d\n", &P, &N);
for ( int i = 0 ; i < N ; i ++)
{
int tmp;
scanf("%d", &tmp);
T.push_back(tmp);
}
sort(T.begin(), T.end());
int i = 0;
int sum = 0;
P -= 1;
while ( T.size() > i && P - T[i] >= 0 )
{
sum += P;
P -= T[i];
i++;
}
printf("%d %d",i, sum);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |