Submission #3391

#TimeUsernameProblemLanguageResultExecution timeMemory
3391mjy0503King of penalty (kriii1_K)C++98
1 / 1
24 ms1476 KiB
#include <stdio.h> #include <algorithm> #include <string.h> #include <vector> int n,su[100001]; int main(){ int n,m,i; scanf("%d %d",&m,&n); for(i=0;i<n;i++) scanf("%d",&su[i]); std::sort(su,su+n); int sum=0,s; long long print=0,now; for(i=0;i<n;i++){ if(sum+su[i]>=m) break; sum+=su[i]; } s=i; i--; now=m-sum-1; for(;i>=0;i--){ print+=now+su[i]; now+=su[i]; } printf("%d %lld\n",s,print); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...