# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3389 | jihoon | King of penalty (kriii1_K) | C++98 | 24 ms | 1476 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |