답안 #218106

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218106 2020-04-01T08:34:21 Z PeppaPig Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
142 ms 131576 KB
#include <bits/stdc++.h>

#define long long long

using namespace std;

const int N = 205;


int n, l, ans;
int x[N], t[N];
long L[N][N][N], R[N][N][N];

long d(int a, int b) { return min(abs(x[b] - x[a]), l - abs(x[b] - x[a])); }

int main() {
    scanf("%d %d", &n, &l);
    for(int i = 1; i <= n; i++) scanf("%d", x + i); 
    for(int i = 1; i <= n; i++) scanf("%d", t + i); 
    x[n + 1] = l;

    for(int k = 0; k <= n; k++) for(int i = 0; i <= n; i++) for(int j = n + 1; j; j--) {
        if(j <= i || (!i && j == n + 1 && !k)) continue;
        L[k][i][j] = R[k][i][j] = 1e18;

        if(i) L[k][i][j] = min({L[k][i][j], L[k][i-1][j] + d(i-1, i), R[k][i-1][j] + d(i, j)});
        if(j <= n) R[k][i][j] = min({R[k][i][j], L[k][i][j+1] + d(i, j), R[k][i][j+1] + d(j+1, j)});

        if(k) {
            if(i) {
                long T = min(L[k-1][i-1][j] + d(i-1, i), R[k-1][i-1][j] + d(j, i));
                if(T <= t[i]) L[k][i][j] = min(L[k][i][j], T);
            }
            if(j <= n) {
                long T = min(L[k-1][i][j+1] + d(i, j), R[k-1][i][j+1] + d(j+1, j));
                if(T <= t[j]) R[k][i][j] = min(R[k][i][j], T);
            }
        }
        if(L[k][i][j] != 1e18 || R[k][i][j] != 1e18)
            ans = max(ans, k);
    }
    printf("%d\n", ans);

    return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &l);
     ~~~~~^~~~~~~~~~~~~~~~~
ho_t3.cpp:18:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%d", x + i); 
                                 ~~~~~^~~~~~~~~~~~~
ho_t3.cpp:19:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%d", t + i); 
                                 ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 5 ms 768 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 5 ms 640 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 5 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 5 ms 768 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 5 ms 640 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 5 ms 896 KB Output is correct
18 Correct 5 ms 1152 KB Output is correct
19 Correct 11 ms 768 KB Output is correct
20 Correct 5 ms 1024 KB Output is correct
21 Correct 5 ms 1152 KB Output is correct
22 Correct 5 ms 768 KB Output is correct
23 Correct 5 ms 1280 KB Output is correct
24 Correct 5 ms 1024 KB Output is correct
25 Correct 5 ms 1152 KB Output is correct
26 Correct 5 ms 1152 KB Output is correct
27 Correct 5 ms 640 KB Output is correct
28 Correct 5 ms 768 KB Output is correct
29 Correct 5 ms 1280 KB Output is correct
30 Correct 5 ms 1280 KB Output is correct
31 Correct 5 ms 1152 KB Output is correct
32 Correct 5 ms 1024 KB Output is correct
33 Correct 5 ms 1280 KB Output is correct
34 Correct 5 ms 1280 KB Output is correct
35 Correct 5 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 5 ms 768 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 5 ms 640 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 5 ms 896 KB Output is correct
18 Correct 105 ms 105724 KB Output is correct
19 Correct 60 ms 64248 KB Output is correct
20 Correct 38 ms 34432 KB Output is correct
21 Correct 56 ms 60664 KB Output is correct
22 Correct 77 ms 78584 KB Output is correct
23 Correct 26 ms 29312 KB Output is correct
24 Correct 20 ms 23040 KB Output is correct
25 Correct 26 ms 28664 KB Output is correct
26 Correct 11 ms 11136 KB Output is correct
27 Correct 26 ms 29952 KB Output is correct
28 Correct 19 ms 21376 KB Output is correct
29 Correct 27 ms 30584 KB Output is correct
30 Correct 21 ms 24192 KB Output is correct
31 Correct 25 ms 28664 KB Output is correct
32 Correct 15 ms 15232 KB Output is correct
33 Correct 26 ms 28800 KB Output is correct
34 Correct 11 ms 10368 KB Output is correct
35 Correct 25 ms 28160 KB Output is correct
36 Correct 12 ms 13440 KB Output is correct
37 Correct 26 ms 29952 KB Output is correct
38 Correct 15 ms 16512 KB Output is correct
39 Correct 27 ms 31232 KB Output is correct
40 Correct 16 ms 18432 KB Output is correct
41 Correct 140 ms 130296 KB Output is correct
42 Correct 85 ms 87928 KB Output is correct
43 Correct 137 ms 130296 KB Output is correct
44 Correct 83 ms 86888 KB Output is correct
45 Correct 142 ms 130412 KB Output is correct
46 Correct 83 ms 87928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 5 ms 768 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 5 ms 768 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
13 Correct 5 ms 896 KB Output is correct
14 Correct 5 ms 640 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 5 ms 896 KB Output is correct
18 Correct 5 ms 1152 KB Output is correct
19 Correct 11 ms 768 KB Output is correct
20 Correct 5 ms 1024 KB Output is correct
21 Correct 5 ms 1152 KB Output is correct
22 Correct 5 ms 768 KB Output is correct
23 Correct 5 ms 1280 KB Output is correct
24 Correct 5 ms 1024 KB Output is correct
25 Correct 5 ms 1152 KB Output is correct
26 Correct 5 ms 1152 KB Output is correct
27 Correct 5 ms 640 KB Output is correct
28 Correct 5 ms 768 KB Output is correct
29 Correct 5 ms 1280 KB Output is correct
30 Correct 5 ms 1280 KB Output is correct
31 Correct 5 ms 1152 KB Output is correct
32 Correct 5 ms 1024 KB Output is correct
33 Correct 5 ms 1280 KB Output is correct
34 Correct 5 ms 1280 KB Output is correct
35 Correct 5 ms 1280 KB Output is correct
36 Correct 105 ms 105724 KB Output is correct
37 Correct 60 ms 64248 KB Output is correct
38 Correct 38 ms 34432 KB Output is correct
39 Correct 56 ms 60664 KB Output is correct
40 Correct 77 ms 78584 KB Output is correct
41 Correct 26 ms 29312 KB Output is correct
42 Correct 20 ms 23040 KB Output is correct
43 Correct 26 ms 28664 KB Output is correct
44 Correct 11 ms 11136 KB Output is correct
45 Correct 26 ms 29952 KB Output is correct
46 Correct 19 ms 21376 KB Output is correct
47 Correct 27 ms 30584 KB Output is correct
48 Correct 21 ms 24192 KB Output is correct
49 Correct 25 ms 28664 KB Output is correct
50 Correct 15 ms 15232 KB Output is correct
51 Correct 26 ms 28800 KB Output is correct
52 Correct 11 ms 10368 KB Output is correct
53 Correct 25 ms 28160 KB Output is correct
54 Correct 12 ms 13440 KB Output is correct
55 Correct 26 ms 29952 KB Output is correct
56 Correct 15 ms 16512 KB Output is correct
57 Correct 27 ms 31232 KB Output is correct
58 Correct 16 ms 18432 KB Output is correct
59 Correct 140 ms 130296 KB Output is correct
60 Correct 85 ms 87928 KB Output is correct
61 Correct 137 ms 130296 KB Output is correct
62 Correct 83 ms 86888 KB Output is correct
63 Correct 142 ms 130412 KB Output is correct
64 Correct 83 ms 87928 KB Output is correct
65 Correct 121 ms 117624 KB Output is correct
66 Correct 108 ms 108024 KB Output is correct
67 Correct 103 ms 103416 KB Output is correct
68 Correct 94 ms 95480 KB Output is correct
69 Correct 122 ms 116472 KB Output is correct
70 Correct 116 ms 111608 KB Output is correct
71 Correct 113 ms 112760 KB Output is correct
72 Correct 121 ms 113948 KB Output is correct
73 Correct 105 ms 105724 KB Output is correct
74 Correct 99 ms 98808 KB Output is correct
75 Correct 110 ms 109304 KB Output is correct
76 Correct 141 ms 125304 KB Output is correct
77 Correct 128 ms 125176 KB Output is correct
78 Correct 100 ms 96632 KB Output is correct
79 Correct 101 ms 99960 KB Output is correct
80 Correct 135 ms 122744 KB Output is correct
81 Correct 99 ms 101112 KB Output is correct
82 Correct 109 ms 106872 KB Output is correct
83 Correct 138 ms 130296 KB Output is correct
84 Correct 113 ms 111608 KB Output is correct
85 Correct 128 ms 121592 KB Output is correct
86 Correct 123 ms 118904 KB Output is correct
87 Correct 109 ms 109176 KB Output is correct
88 Correct 140 ms 131576 KB Output is correct
89 Correct 137 ms 131576 KB Output is correct
90 Correct 110 ms 110456 KB Output is correct
91 Correct 141 ms 131576 KB Output is correct
92 Correct 139 ms 131552 KB Output is correct
93 Correct 132 ms 129008 KB Output is correct