# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4179 | hsswill | King of penalty (kriii1_K) | C++98 | 0 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 std::sort;
int data[100011];
int main(void)
{
int a, i, sum, n, t = 0, result;
scanf("%d %d",&a,&n);
for(i = 0; i < n; i++)
scanf("%d",&data[i]);
sort( data, data+n );
sum = 0;
for(i = 0; i < n; i++)
{
sum += data[i];
if( sum >= a ) break;
}
result = i;
sum = t = 0;
for(i = result-1; i >= 0; i--)
{
sum += data[i];
t += sum;
}
printf("%d %d",result,t+a);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |