Submission #18855

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