Submission #3389

#TimeUsernameProblemLanguageResultExecution timeMemory
3389jihoonKing of penalty (kriii1_K)C++98
0 / 1
24 ms1476 KiB
#include<stdio.h> #include<algorithm> using namespace std; int prob[100001]={0}; int main(){ int n; long long int cnt=0; int ti=0; int t; int i; scanf("%d %d",&t,&n); for(i=0;i<n;i++){ scanf("%d",&prob[i]); } sort(prob,prob+n); for(i=0;i<n;i++){ if(ti+prob[i]>=t) break; ti+=prob[i]; cnt+=((i+1)*prob[i]); } cnt+=(t-ti-1)*i; printf("%d %lld",i,cnt); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...