# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4277 | girl4930 | King of penalty (kriii1_K) | C++98 | 20 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 farr[100000];
int main(){
int p=0, n=0;
long long sum=0, tmp=0;
int count=0, i=0;
scanf("%d %d",&p,&n);
for(i=0;i<n;i++)
scanf("%d",&farr[i]);
sort(farr,farr+n);
for(i=0;i<n;i++) {
if( tmp + farr[i] >= p ) break;
tmp = tmp + farr[i];
}
tmp = p-tmp-1;
count = i;
for( i= i-1;i>=0;i--){
tmp = tmp+farr[i];
sum = sum+tmp;
}
printf("%d %lld",count,sum);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |