답안 #727908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727908 2023-04-21T14:40:16 Z Boycl07 선물상자 (IOI15_boxes) C++17
100 / 100
557 ms 275220 KB
#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define forn(i, l, r) for(int i = l; i <= r; ++i)
#define ford(i, r, l) for(int i = r; i >= l; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define C(x, y) make_pair(x, y)

template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }


const int MN =  1e7 + 7;
const int MOD = 1e9 + 7 ;
const int INF = 1e13 + 9999;
const int block_size = 230;
const int LIM = 2e7;

ll pre[MN], suf[MN];


long long delivery(int N, int K, int L, int p[])
{
    ll res = 1e18;
    rep(i, N)
    {
        pre[i] = pre[max(0, i - K)] + min(p[i - 1] + min(p[i - 1], L - p[i - 1]),
                                    L - p[max(0, i - K)] + min(p[max(0, i - K)], L - p[max(0, i - K)]));
    }
    ford(i, N, 1)
    {
        suf[i] = suf[min(N + 1, i + K)] + min(L - p[i - 1] + min(p[i - 1], L - p[i - 1]),
                                p[min(N - 1, i + K - 2)] + min(p[min(N - 1, i + K - 2)], L - p[min(N - 1, i + K - 2)]));
    }
    rep(i, N) minimize(res, pre[i] + suf[i + 1]);
    return res;

}

Compilation message

boxes.cpp:23:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000009999e+13' to '2147483647' [-Woverflow]
   23 | const int INF = 1e13 + 9999;
      |                 ~~~~~^~~~~~
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 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 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 212 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 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 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 212 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 320 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 320 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 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 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 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 212 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 320 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 320 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 58 ms 29596 KB Output is correct
34 Correct 24 ms 21760 KB Output is correct
35 Correct 25 ms 22216 KB Output is correct
36 Correct 55 ms 29536 KB Output is correct
37 Correct 53 ms 29640 KB Output is correct
38 Correct 55 ms 29644 KB Output is correct
39 Correct 49 ms 28048 KB Output is correct
40 Correct 30 ms 23452 KB Output is correct
41 Correct 55 ms 29576 KB Output is correct
42 Correct 31 ms 23700 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 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 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 212 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 320 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 320 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 58 ms 29596 KB Output is correct
34 Correct 24 ms 21760 KB Output is correct
35 Correct 25 ms 22216 KB Output is correct
36 Correct 55 ms 29536 KB Output is correct
37 Correct 53 ms 29640 KB Output is correct
38 Correct 55 ms 29644 KB Output is correct
39 Correct 49 ms 28048 KB Output is correct
40 Correct 30 ms 23452 KB Output is correct
41 Correct 55 ms 29576 KB Output is correct
42 Correct 31 ms 23700 KB Output is correct
43 Correct 546 ms 262108 KB Output is correct
44 Correct 210 ms 215528 KB Output is correct
45 Correct 239 ms 223232 KB Output is correct
46 Correct 557 ms 273196 KB Output is correct
47 Correct 523 ms 275220 KB Output is correct
48 Correct 543 ms 260072 KB Output is correct
49 Correct 492 ms 259612 KB Output is correct
50 Correct 291 ms 232384 KB Output is correct
51 Correct 535 ms 275144 KB Output is correct
52 Correct 312 ms 234740 KB Output is correct