# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3570 | BothEarRim | King of penalty (kriii1_K) | C++98 | 24 ms | 1868 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;
long long num[100000]={0};
int main()
{
long long p,i,j,n;
long long sum=0,res=0,temp;
scanf("%lld %lld",&p,&n);
for(i=0 ; i<n ; i++){
scanf("%lld",&num[i]);
}i=0;
sort(num,num+n);
while(sum + num[i] <= p-1){
sum += num[i++];
}
printf("%d ",i);
temp = p-1-sum;
while(i--){
res += temp + num[i];
temp += num[i];
}
printf("%lld\n",res);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |