Submission #4277

#TimeUsernameProblemLanguageResultExecution timeMemory
4277girl4930King of penalty (kriii1_K)C++98
1 / 1
20 ms1476 KiB
#include<stdio.h> #include<algorithm> using namespace std; int farr[100000]; int main(){ int p=0, n=0; long long sum=0, tmp=0; int count=0, i=0; scanf("%d %d",&p,&n); for(i=0;i<n;i++) scanf("%d",&farr[i]); sort(farr,farr+n); for(i=0;i<n;i++) { if( tmp + farr[i] >= p ) break; tmp = tmp + farr[i]; } tmp = p-tmp-1; count = i; for( i= i-1;i>=0;i--){ tmp = tmp+farr[i]; sum = sum+tmp; } printf("%d %lld",count,sum); }
#Verdict Execution timeMemoryGrader output
Fetching results...