Submission #18600

#TimeUsernameProblemLanguageResultExecution timeMemory
18600eaststarKing of penalty (kriii1_K)C++14
1 / 1
32 ms1472 KiB
#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 timeMemoryGrader output
Fetching results...