# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4346 | zorrapower | King of penalty (kriii1_K) | C++98 | 28 ms | 1868 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;
#define MAX_NUMBER 100000
long long SolveTime[MAX_NUMBER];
int main(void){
long long P;
long long N;
long long Possible;
long long PAT=0;
long long START_TIME;
scanf("%lld %lld", &P, &N);
for(int i=0; i<N; i++){
scanf("%lld", &SolveTime[i]);
}
sort(SolveTime,SolveTime+N);
long long SUM=0;
for(int i=0; i<N; i++){
SUM+=SolveTime[i];
Possible=i;
if(SUM>=P){
i--;
break;
}
}
if(SUM<=P)
Possible++;
printf("%lld\n", Possible);
START_TIME=P;
for(int i=0; i<Possible; i++){
START_TIME-=SolveTime[i];
}
START_TIME--;
PAT+=START_TIME*Possible;
for(int i=0; i<Possible; i++){
PAT+=SolveTime[i]*(i+1);
}
printf("%lld\n", PAT);
scanf("%*d");
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |