# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
18855 | Namnamseo | King of penalty (kriii1_K) | C++14 | 25 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 <cstdio>
#include <algorithm>
using namespace std;
int p,n;
int data[100010];
int main()
{
scanf("%d%d",&p,&n);
int i;
for(i=0;i<n;++i) scanf("%d",data+i);
sort(data,data+n);
int cs=0;
for(i=0;i<n;++i){
if(data[i]+cs>=p) break;
else cs+=data[i];
}
printf("%d ",i);
int j;
typedef long long ll;
ll ans=0, tmp=p-1-cs;
for(j=i-1;j>=0;--j){
tmp+=data[j];
ans+=tmp;
}
printf("%lld\n",ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |