답안 #390765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390765 2021-04-16T21:23:49 Z timmyfeng Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
77 ms 64464 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 202, T = 1000000000;

int x[N], t[N], early[N][N][N][2];

void set_min(int &a, int b) {
    a = min(a, b);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, c;
    cin >> n >> c;

    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
    }
    x[n + 1] = c;

    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }

    for (int l = 0; l <= n; ++l) {
        for (int r = 0; r <= n; ++r) {
            for (int i = 0; i <= n; ++i) {
                for (int j = 0; j < 2; ++j) {
                    early[l][r][i][j] = T + 1;
                }
            }
        }
    }

    early[0][0][0][0] = early[0][0][0][1] = 0;

    for (int i = 0; i < n; ++i) {
        for (int l = 0; l <= i; ++l) {
            int r = i - l, s;
            for (int j = 0; j <= i; ++j) {
                if (early[l][r][j][0] <= T) {
                    s = early[l][r][j][0] + x[l + 1] - x[l];
                    set_min(early[l + 1][r][j + (s <= t[l])][0], s);

                    s = early[l][r][j][0] + x[l] + c - x[n - r];
                    set_min(early[l][r + 1][j + (s <= t[n - 1 - r])][1], s);
                }

                if (early[l][r][j][1] <= T) {
                    s = early[l][r][j][1] + x[l + 1] + c - x[n + 1 - r];
                    set_min(early[l + 1][r][j + (s <= t[l])][0], s);

                    s = early[l][r][j][1] + x[n + 1 - r] - x[n - r];
                    set_min(early[l][r + 1][j + (s <= t[n - 1 - r])][1], s);
                }
            }
        }
    }

    int ans = 0;
    for (int l = 0; l <= n; ++l) {
        int r = n - l;
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j < 2; ++j) {
                if (early[l][r][i][j] <= T) {
                    ans = max(ans, i);
                }
            }
        }
    }

    cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 472 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 472 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 728 KB Output is correct
19 Correct 1 ms 472 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 728 KB Output is correct
22 Correct 1 ms 472 KB Output is correct
23 Correct 1 ms 728 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 728 KB Output is correct
26 Correct 1 ms 728 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 472 KB Output is correct
29 Correct 1 ms 728 KB Output is correct
30 Correct 1 ms 728 KB Output is correct
31 Correct 1 ms 728 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 728 KB Output is correct
34 Correct 1 ms 728 KB Output is correct
35 Correct 1 ms 720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 472 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 56 ms 52152 KB Output is correct
19 Correct 31 ms 31848 KB Output is correct
20 Correct 14 ms 17120 KB Output is correct
21 Correct 28 ms 30084 KB Output is correct
22 Correct 42 ms 38848 KB Output is correct
23 Correct 14 ms 14552 KB Output is correct
24 Correct 8 ms 11480 KB Output is correct
25 Correct 13 ms 14340 KB Output is correct
26 Correct 4 ms 5592 KB Output is correct
27 Correct 14 ms 14876 KB Output is correct
28 Correct 7 ms 10712 KB Output is correct
29 Correct 13 ms 15132 KB Output is correct
30 Correct 9 ms 11992 KB Output is correct
31 Correct 12 ms 14296 KB Output is correct
32 Correct 6 ms 7636 KB Output is correct
33 Correct 13 ms 14296 KB Output is correct
34 Correct 4 ms 5208 KB Output is correct
35 Correct 10 ms 14028 KB Output is correct
36 Correct 5 ms 6744 KB Output is correct
37 Correct 11 ms 14820 KB Output is correct
38 Correct 6 ms 8280 KB Output is correct
39 Correct 12 ms 15580 KB Output is correct
40 Correct 6 ms 9176 KB Output is correct
41 Correct 72 ms 64080 KB Output is correct
42 Correct 30 ms 43468 KB Output is correct
43 Correct 77 ms 64108 KB Output is correct
44 Correct 30 ms 42948 KB Output is correct
45 Correct 76 ms 64076 KB Output is correct
46 Correct 30 ms 43408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 1 ms 456 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 472 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 728 KB Output is correct
19 Correct 1 ms 472 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 728 KB Output is correct
22 Correct 1 ms 472 KB Output is correct
23 Correct 1 ms 728 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 728 KB Output is correct
26 Correct 1 ms 728 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 472 KB Output is correct
29 Correct 1 ms 728 KB Output is correct
30 Correct 1 ms 728 KB Output is correct
31 Correct 1 ms 728 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 728 KB Output is correct
34 Correct 1 ms 728 KB Output is correct
35 Correct 1 ms 720 KB Output is correct
36 Correct 56 ms 52152 KB Output is correct
37 Correct 31 ms 31848 KB Output is correct
38 Correct 14 ms 17120 KB Output is correct
39 Correct 28 ms 30084 KB Output is correct
40 Correct 42 ms 38848 KB Output is correct
41 Correct 14 ms 14552 KB Output is correct
42 Correct 8 ms 11480 KB Output is correct
43 Correct 13 ms 14340 KB Output is correct
44 Correct 4 ms 5592 KB Output is correct
45 Correct 14 ms 14876 KB Output is correct
46 Correct 7 ms 10712 KB Output is correct
47 Correct 13 ms 15132 KB Output is correct
48 Correct 9 ms 11992 KB Output is correct
49 Correct 12 ms 14296 KB Output is correct
50 Correct 6 ms 7636 KB Output is correct
51 Correct 13 ms 14296 KB Output is correct
52 Correct 4 ms 5208 KB Output is correct
53 Correct 10 ms 14028 KB Output is correct
54 Correct 5 ms 6744 KB Output is correct
55 Correct 11 ms 14820 KB Output is correct
56 Correct 6 ms 8280 KB Output is correct
57 Correct 12 ms 15580 KB Output is correct
58 Correct 6 ms 9176 KB Output is correct
59 Correct 72 ms 64080 KB Output is correct
60 Correct 30 ms 43468 KB Output is correct
61 Correct 77 ms 64108 KB Output is correct
62 Correct 30 ms 42948 KB Output is correct
63 Correct 76 ms 64076 KB Output is correct
64 Correct 30 ms 43408 KB Output is correct
65 Correct 44 ms 58244 KB Output is correct
66 Correct 40 ms 53344 KB Output is correct
67 Correct 39 ms 51020 KB Output is correct
68 Correct 34 ms 47084 KB Output is correct
69 Correct 44 ms 57496 KB Output is correct
70 Correct 42 ms 55064 KB Output is correct
71 Correct 39 ms 55620 KB Output is correct
72 Correct 43 ms 56240 KB Output is correct
73 Correct 36 ms 52248 KB Output is correct
74 Correct 38 ms 48772 KB Output is correct
75 Correct 37 ms 53984 KB Output is correct
76 Correct 56 ms 61816 KB Output is correct
77 Correct 45 ms 61856 KB Output is correct
78 Correct 47 ms 47668 KB Output is correct
79 Correct 35 ms 49308 KB Output is correct
80 Correct 54 ms 60476 KB Output is correct
81 Correct 34 ms 49900 KB Output is correct
82 Correct 44 ms 52744 KB Output is correct
83 Correct 47 ms 64140 KB Output is correct
84 Correct 45 ms 55212 KB Output is correct
85 Correct 43 ms 59896 KB Output is correct
86 Correct 56 ms 58672 KB Output is correct
87 Correct 40 ms 53916 KB Output is correct
88 Correct 51 ms 64408 KB Output is correct
89 Correct 46 ms 64432 KB Output is correct
90 Correct 39 ms 54484 KB Output is correct
91 Correct 51 ms 64464 KB Output is correct
92 Correct 48 ms 64452 KB Output is correct
93 Correct 45 ms 63656 KB Output is correct