Submission #3480

#TimeUsernameProblemLanguageResultExecution timeMemory
3480cki86201King of penalty (kriii1_K)C++98
1 / 1
24 ms1476 KiB
#include<stdio.h> #include<algorithm> #include<string.h> #include<vector> #include<math.h> #include<stdlib.h> using namespace std; int p[100010],n,k; int main() { scanf("%d%d",&k,&n); int i; for(i=0;i<n;i++)scanf("%d",p+i); sort(p,p+n); long long s=0; for(i=0;i<n;i++){ if(s>=k)break; s+=p[i]; if(s>=k)break; } printf("%d ",i); long long ans=0,t=0; for(int j=0;j<i;j++){ ans+=(k-1-t); t+=p[j]; } printf("%lld",ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...