Submission #3506

#TimeUsernameProblemLanguageResultExecution timeMemory
3506imsifileKing of penalty (kriii1_K)C++98
1 / 1
24 ms1956 KiB
#include<stdio.h> #include<algorithm> using namespace std; long long p, n, ba[111111], cnt, hh, dap, i; int main(){ scanf("%lld%lld", &p,&n); for(i=0; i<n; i++)scanf("%lld", &ba[i]); sort(ba, ba+n); for(i=0; i<n; i++){ if(hh+ba[i]>=p)break; cnt++, hh+=ba[i]; } hh=p-1; for(i=0; i<cnt; i++)dap+=hh, hh-=ba[i]; printf("%lld %lld", cnt, dap); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...