답안 #798430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798430 2023-07-30T17:15:33 Z qthang2k11 선물상자 (IOI15_boxes) C++17
100 / 100
464 ms 293844 KB
#include "boxes.h"
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int N = 1e7 + 5;

ll pref[N], suff[N];
int *p;

ll delivery(int n, int k, int m, int _p[]) { // n <= m, duoc dua toi da k
  if (m == 1) return 0;
  // if (n == 1) return min({m - 1, p[0] * 2, });
  p = _p;
  for (int i = 0; i < n; i++) {
    pref[i] = (i - k >= 0 ? pref[i - k] : 0) + 2LL * p[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    suff[i] = (i + k < n ? suff[i + k] : 0) + 2LL * (m - p[i]);
  }
  ll ans = min(1LL * m * n, suff[0]);
  for (int i = 0; i < n; i++) {
    ans = min(ans, pref[i] + suff[i + 1]);
    ll cur = 0;
    if (i - 1 >= 0) cur += pref[i - 1];
    if (i + k < n) cur += suff[i + k];
    cur += m;
    ans = min(ans, cur);
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 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 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 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 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 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 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 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 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 44 ms 29492 KB Output is correct
34 Correct 18 ms 21836 KB Output is correct
35 Correct 20 ms 22280 KB Output is correct
36 Correct 46 ms 29616 KB Output is correct
37 Correct 46 ms 29680 KB Output is correct
38 Correct 45 ms 29612 KB Output is correct
39 Correct 40 ms 28108 KB Output is correct
40 Correct 22 ms 23464 KB Output is correct
41 Correct 44 ms 29612 KB Output is correct
42 Correct 24 ms 23708 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 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 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 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 44 ms 29492 KB Output is correct
34 Correct 18 ms 21836 KB Output is correct
35 Correct 20 ms 22280 KB Output is correct
36 Correct 46 ms 29616 KB Output is correct
37 Correct 46 ms 29680 KB Output is correct
38 Correct 45 ms 29612 KB Output is correct
39 Correct 40 ms 28108 KB Output is correct
40 Correct 22 ms 23464 KB Output is correct
41 Correct 44 ms 29612 KB Output is correct
42 Correct 24 ms 23708 KB Output is correct
43 Correct 464 ms 292664 KB Output is correct
44 Correct 174 ms 215472 KB Output is correct
45 Correct 197 ms 223368 KB Output is correct
46 Correct 455 ms 293844 KB Output is correct
47 Correct 443 ms 293804 KB Output is correct
48 Correct 464 ms 293756 KB Output is correct
49 Correct 424 ms 278572 KB Output is correct
50 Correct 239 ms 232436 KB Output is correct
51 Correct 462 ms 293652 KB Output is correct
52 Correct 267 ms 235020 KB Output is correct