# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
4176 | pl0892029 | King of penalty (kriii1_K) | C++98 | 20 ms | 1472 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main() {
int p, t, t1;
int *pt;
int i, num;
long long penalty=0, tmp=0, wait;
scanf("%d %d", &t, &p);
pt = (int *)malloc(sizeof(int)*p);
for(i=0;i<p;i++)
scanf("%d", &pt[i]);
sort(pt,pt+p);
i=0;
t1 = t;
while(true) {
t1-=pt[i];
if(t1<=0 || i==p)
break;
penalty+=pt[i];
i++;
}
num=i;
wait = t-penalty-1;
for(i=num-1;i>=0;i--) {
wait+=pt[i];
tmp+=wait;
}
free(pt);
printf("%d %lld\n", num, tmp);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |