Submission #3405

#TimeUsernameProblemLanguageResultExecution timeMemory
3405pichuliaKing of penalty (kriii1_K)C++98
1 / 1
24 ms1476 KiB
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<algorithm> using namespace::std; int a[100008]; int n, m; void input() { scanf("%d %d",&m,&n); for(int i=0; i<n; i++) scanf("%d",&a[i]); sort(a,a+n); } void process() { int i, j; j=0; long long int k=0, l=0; for(i=0; i<n; i++) { j+=a[i]; if(j>=m) { break; } } printf("%d ",i); for(j=0; j<i;j++) { k += (m-1-l); l += a[j]; } printf("%lld",k); } void output() { } int main() { input(); process(); output(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...