# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3391 | mjy0503 | King of penalty (kriii1_K) | C++98 | 24 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>
#include <string.h>
#include <vector>
int n,su[100001];
int main(){
int n,m,i;
scanf("%d %d",&m,&n);
for(i=0;i<n;i++)
scanf("%d",&su[i]);
std::sort(su,su+n);
int sum=0,s;
long long print=0,now;
for(i=0;i<n;i++){
if(sum+su[i]>=m) break;
sum+=su[i];
}
s=i;
i--;
now=m-sum-1;
for(;i>=0;i--){
print+=now+su[i];
now+=su[i];
}
printf("%d %lld\n",s,print);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |