# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18600 | eaststar | King of penalty (kriii1_K) | C++14 | 32 ms | 1472 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 a[100010],t;
long long s;
int main(){
int i,p,n;
scanf("%d%d",&p,&n);
for(i=1;i<=n;++i)scanf("%d",a+i);
sort(a+1,a+n+1);
for(i=1;i<=n;++i){
if(t+a[i]>=p)break;
t+=a[i];
}
p-=t+1,t=0;
for(n=--i;i;--i)t+=a[i],s+=t;
printf("%d %lld",n,(long long)p*n+s);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |