답안 #736796

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
736796 2023-05-06T08:36:30 Z PoonYaPat 선물상자 (IOI15_boxes) C++14
100 / 100
771 ms 293960 KB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll pre[10000010],suf[10000010];

long long delivery(int n, int k, int l, int pos[]) {
    sort(pos,pos+n);

    pre[0]=0;
    for (int i=0; i<n; ++i) pre[i+1]=pre[max(0,i+1-k)]+2*pos[i];

    suf[n+1]=0;
    for (int i=n-1; i>=0; --i) suf[i+1]=suf[min(n+1,i+1+k)]+2*(l-pos[i]);

    ll ans=LLONG_MAX;
    for (int i=0; i<=n; ++i) ans=min(ans,pre[i]+suf[i+1]);
    for (int i=0; i<=n-k; ++i) ans=min(ans,pre[i]+suf[i+k+1]+l);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 312 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 312 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 70 ms 29516 KB Output is correct
34 Correct 33 ms 21780 KB Output is correct
35 Correct 37 ms 22220 KB Output is correct
36 Correct 65 ms 29644 KB Output is correct
37 Correct 66 ms 29660 KB Output is correct
38 Correct 66 ms 29588 KB Output is correct
39 Correct 69 ms 28028 KB Output is correct
40 Correct 43 ms 23508 KB Output is correct
41 Correct 67 ms 29624 KB Output is correct
42 Correct 41 ms 23716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 312 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 70 ms 29516 KB Output is correct
34 Correct 33 ms 21780 KB Output is correct
35 Correct 37 ms 22220 KB Output is correct
36 Correct 65 ms 29644 KB Output is correct
37 Correct 66 ms 29660 KB Output is correct
38 Correct 66 ms 29588 KB Output is correct
39 Correct 69 ms 28028 KB Output is correct
40 Correct 43 ms 23508 KB Output is correct
41 Correct 67 ms 29624 KB Output is correct
42 Correct 41 ms 23716 KB Output is correct
43 Correct 759 ms 292788 KB Output is correct
44 Correct 347 ms 215560 KB Output is correct
45 Correct 369 ms 223308 KB Output is correct
46 Correct 674 ms 293944 KB Output is correct
47 Correct 652 ms 293932 KB Output is correct
48 Correct 656 ms 293912 KB Output is correct
49 Correct 721 ms 278592 KB Output is correct
50 Correct 469 ms 232452 KB Output is correct
51 Correct 771 ms 293960 KB Output is correct
52 Correct 450 ms 235144 KB Output is correct