# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3627 | MiNu | King of penalty (kriii1_K) | C++98 | 24 ms | 1936 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 <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int n, p;
scanf("%d %d", &p, &n);
int t[n+1];
int s = 0;
for ( int i=0 ; i<n ; ++i )
{
scanf("%d", &t[i]);
}
sort(t, t+n);
int k = 0;
for ( int i=0 ; i<n ; ++i )
{
if ( s + t[i] < p )
{
s += t[i];
++k;
}
else
{
k = i;
break;
}
}
int e = p - s - 1;
long long total = 0LL;
for ( int i=k-1 ; i>=0 ; --i )
{
e += t[i];
total += e;
}
cout << k << " " << total << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |