답안 #202459

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
202459 2020-02-16T07:59:03 Z Kastanda Collecting Stamps 3 (JOI20_ho_t3) C++11
100 / 100
168 ms 143356 KB
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 209;
int n, L, X[N], T[N];
long long dp[N][N][N][2];
inline void SMin(long long &a, long long b)
{
    a = min(a, b);
}
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]);
    memset(dp, 63, sizeof(dp));
    dp[1][n + 1][X[1] <= T[1]][0] = X[1];
    dp[0][n][L - X[n] <= T[n]][1] = L - X[n];
    for (int len = n; len; len --)
        for (int l = 0, r = len; r <= n + 1; l ++, r ++)
            for (int c = 0; c <= l + n + 1 - r; c ++)
            {
                /// w = 0 : We're at l.
                // Increase l :
                SMin(dp[l + 1][r][c + (dp[l][r][c][0] + X[l + 1] - X[l] <= T[l + 1])][0], dp[l][r][c][0] + X[l + 1] - X[l]);
                // Decrease r :
                SMin(dp[l][r - 1][c + (dp[l][r][c][0] + L - X[r - 1] + X[l] <= T[r - 1])][1], dp[l][r][c][0] + L - X[r - 1] + X[l]);
                /// w = 1 : We're at r.
                // Increase l :
                SMin(dp[l + 1][r][c + (dp[l][r][c][1] + L - X[r] + X[l + 1] <= T[l + 1])][0], dp[l][r][c][1] + L - X[r] + X[l + 1]);
                // Decrease r :
                SMin(dp[l][r - 1][c + (dp[l][r][c][1] + X[r] - X[r - 1] <= T[r - 1])][1], dp[l][r][c][1] + X[r] - X[r - 1]);
            }
    int Mx = 0;
    for (int l = 0; l <= n; l ++)
        for (int c = 0; c <= n; c ++)
            for (int w = 0; w <= 1; w ++)
                if (dp[l][l + 1][c][w] <= 1LL * n * L)
                    Mx = max(Mx, c);
    return !printf("%d\n", Mx);
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:13: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:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &X[i]);
         ~~~~~^~~~~~~~~~~~~
ho_t3.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &T[i]);
         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 143224 KB Output is correct
2 Correct 86 ms 143224 KB Output is correct
3 Correct 85 ms 143224 KB Output is correct
4 Correct 90 ms 143224 KB Output is correct
5 Correct 94 ms 143224 KB Output is correct
6 Correct 96 ms 143224 KB Output is correct
7 Correct 88 ms 143272 KB Output is correct
8 Correct 89 ms 143300 KB Output is correct
9 Correct 86 ms 143164 KB Output is correct
10 Correct 89 ms 143224 KB Output is correct
11 Correct 97 ms 143228 KB Output is correct
12 Correct 92 ms 143224 KB Output is correct
13 Correct 87 ms 143224 KB Output is correct
14 Correct 88 ms 143224 KB Output is correct
15 Correct 87 ms 143224 KB Output is correct
16 Correct 91 ms 143224 KB Output is correct
17 Correct 86 ms 143224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 143224 KB Output is correct
2 Correct 86 ms 143224 KB Output is correct
3 Correct 85 ms 143224 KB Output is correct
4 Correct 90 ms 143224 KB Output is correct
5 Correct 94 ms 143224 KB Output is correct
6 Correct 96 ms 143224 KB Output is correct
7 Correct 88 ms 143272 KB Output is correct
8 Correct 89 ms 143300 KB Output is correct
9 Correct 86 ms 143164 KB Output is correct
10 Correct 89 ms 143224 KB Output is correct
11 Correct 97 ms 143228 KB Output is correct
12 Correct 92 ms 143224 KB Output is correct
13 Correct 87 ms 143224 KB Output is correct
14 Correct 88 ms 143224 KB Output is correct
15 Correct 87 ms 143224 KB Output is correct
16 Correct 91 ms 143224 KB Output is correct
17 Correct 86 ms 143224 KB Output is correct
18 Correct 87 ms 143224 KB Output is correct
19 Correct 87 ms 143224 KB Output is correct
20 Correct 86 ms 143224 KB Output is correct
21 Correct 93 ms 143224 KB Output is correct
22 Correct 84 ms 143224 KB Output is correct
23 Correct 87 ms 143224 KB Output is correct
24 Correct 85 ms 143224 KB Output is correct
25 Correct 84 ms 143224 KB Output is correct
26 Correct 88 ms 143224 KB Output is correct
27 Correct 86 ms 143224 KB Output is correct
28 Correct 83 ms 143248 KB Output is correct
29 Correct 92 ms 143224 KB Output is correct
30 Correct 87 ms 143180 KB Output is correct
31 Correct 89 ms 143224 KB Output is correct
32 Correct 89 ms 143224 KB Output is correct
33 Correct 88 ms 143224 KB Output is correct
34 Correct 85 ms 143224 KB Output is correct
35 Correct 93 ms 143224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 143224 KB Output is correct
2 Correct 86 ms 143224 KB Output is correct
3 Correct 85 ms 143224 KB Output is correct
4 Correct 90 ms 143224 KB Output is correct
5 Correct 94 ms 143224 KB Output is correct
6 Correct 96 ms 143224 KB Output is correct
7 Correct 88 ms 143272 KB Output is correct
8 Correct 89 ms 143300 KB Output is correct
9 Correct 86 ms 143164 KB Output is correct
10 Correct 89 ms 143224 KB Output is correct
11 Correct 97 ms 143228 KB Output is correct
12 Correct 92 ms 143224 KB Output is correct
13 Correct 87 ms 143224 KB Output is correct
14 Correct 88 ms 143224 KB Output is correct
15 Correct 87 ms 143224 KB Output is correct
16 Correct 91 ms 143224 KB Output is correct
17 Correct 86 ms 143224 KB Output is correct
18 Correct 134 ms 143352 KB Output is correct
19 Correct 111 ms 143224 KB Output is correct
20 Correct 93 ms 143268 KB Output is correct
21 Correct 112 ms 143224 KB Output is correct
22 Correct 122 ms 143228 KB Output is correct
23 Correct 94 ms 143224 KB Output is correct
24 Correct 92 ms 143224 KB Output is correct
25 Correct 100 ms 143224 KB Output is correct
26 Correct 89 ms 143224 KB Output is correct
27 Correct 92 ms 143224 KB Output is correct
28 Correct 93 ms 143224 KB Output is correct
29 Correct 93 ms 143224 KB Output is correct
30 Correct 96 ms 143224 KB Output is correct
31 Correct 97 ms 143312 KB Output is correct
32 Correct 89 ms 143224 KB Output is correct
33 Correct 96 ms 143224 KB Output is correct
34 Correct 88 ms 143224 KB Output is correct
35 Correct 94 ms 143352 KB Output is correct
36 Correct 99 ms 143212 KB Output is correct
37 Correct 96 ms 143224 KB Output is correct
38 Correct 89 ms 143224 KB Output is correct
39 Correct 95 ms 143224 KB Output is correct
40 Correct 90 ms 143224 KB Output is correct
41 Correct 151 ms 143352 KB Output is correct
42 Correct 128 ms 143256 KB Output is correct
43 Correct 154 ms 143224 KB Output is correct
44 Correct 122 ms 143328 KB Output is correct
45 Correct 157 ms 143224 KB Output is correct
46 Correct 137 ms 143228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 143224 KB Output is correct
2 Correct 86 ms 143224 KB Output is correct
3 Correct 85 ms 143224 KB Output is correct
4 Correct 90 ms 143224 KB Output is correct
5 Correct 94 ms 143224 KB Output is correct
6 Correct 96 ms 143224 KB Output is correct
7 Correct 88 ms 143272 KB Output is correct
8 Correct 89 ms 143300 KB Output is correct
9 Correct 86 ms 143164 KB Output is correct
10 Correct 89 ms 143224 KB Output is correct
11 Correct 97 ms 143228 KB Output is correct
12 Correct 92 ms 143224 KB Output is correct
13 Correct 87 ms 143224 KB Output is correct
14 Correct 88 ms 143224 KB Output is correct
15 Correct 87 ms 143224 KB Output is correct
16 Correct 91 ms 143224 KB Output is correct
17 Correct 86 ms 143224 KB Output is correct
18 Correct 87 ms 143224 KB Output is correct
19 Correct 87 ms 143224 KB Output is correct
20 Correct 86 ms 143224 KB Output is correct
21 Correct 93 ms 143224 KB Output is correct
22 Correct 84 ms 143224 KB Output is correct
23 Correct 87 ms 143224 KB Output is correct
24 Correct 85 ms 143224 KB Output is correct
25 Correct 84 ms 143224 KB Output is correct
26 Correct 88 ms 143224 KB Output is correct
27 Correct 86 ms 143224 KB Output is correct
28 Correct 83 ms 143248 KB Output is correct
29 Correct 92 ms 143224 KB Output is correct
30 Correct 87 ms 143180 KB Output is correct
31 Correct 89 ms 143224 KB Output is correct
32 Correct 89 ms 143224 KB Output is correct
33 Correct 88 ms 143224 KB Output is correct
34 Correct 85 ms 143224 KB Output is correct
35 Correct 93 ms 143224 KB Output is correct
36 Correct 134 ms 143352 KB Output is correct
37 Correct 111 ms 143224 KB Output is correct
38 Correct 93 ms 143268 KB Output is correct
39 Correct 112 ms 143224 KB Output is correct
40 Correct 122 ms 143228 KB Output is correct
41 Correct 94 ms 143224 KB Output is correct
42 Correct 92 ms 143224 KB Output is correct
43 Correct 100 ms 143224 KB Output is correct
44 Correct 89 ms 143224 KB Output is correct
45 Correct 92 ms 143224 KB Output is correct
46 Correct 93 ms 143224 KB Output is correct
47 Correct 93 ms 143224 KB Output is correct
48 Correct 96 ms 143224 KB Output is correct
49 Correct 97 ms 143312 KB Output is correct
50 Correct 89 ms 143224 KB Output is correct
51 Correct 96 ms 143224 KB Output is correct
52 Correct 88 ms 143224 KB Output is correct
53 Correct 94 ms 143352 KB Output is correct
54 Correct 99 ms 143212 KB Output is correct
55 Correct 96 ms 143224 KB Output is correct
56 Correct 89 ms 143224 KB Output is correct
57 Correct 95 ms 143224 KB Output is correct
58 Correct 90 ms 143224 KB Output is correct
59 Correct 151 ms 143352 KB Output is correct
60 Correct 128 ms 143256 KB Output is correct
61 Correct 154 ms 143224 KB Output is correct
62 Correct 122 ms 143328 KB Output is correct
63 Correct 157 ms 143224 KB Output is correct
64 Correct 137 ms 143228 KB Output is correct
65 Correct 149 ms 143224 KB Output is correct
66 Correct 139 ms 143224 KB Output is correct
67 Correct 141 ms 143352 KB Output is correct
68 Correct 129 ms 143224 KB Output is correct
69 Correct 152 ms 143212 KB Output is correct
70 Correct 145 ms 143224 KB Output is correct
71 Correct 144 ms 143224 KB Output is correct
72 Correct 152 ms 143224 KB Output is correct
73 Correct 146 ms 143352 KB Output is correct
74 Correct 135 ms 143224 KB Output is correct
75 Correct 145 ms 143224 KB Output is correct
76 Correct 153 ms 143356 KB Output is correct
77 Correct 161 ms 143348 KB Output is correct
78 Correct 124 ms 143224 KB Output is correct
79 Correct 136 ms 143224 KB Output is correct
80 Correct 153 ms 143224 KB Output is correct
81 Correct 136 ms 143224 KB Output is correct
82 Correct 137 ms 143224 KB Output is correct
83 Correct 157 ms 143228 KB Output is correct
84 Correct 146 ms 143224 KB Output is correct
85 Correct 152 ms 143168 KB Output is correct
86 Correct 148 ms 143224 KB Output is correct
87 Correct 140 ms 143228 KB Output is correct
88 Correct 168 ms 143224 KB Output is correct
89 Correct 160 ms 143304 KB Output is correct
90 Correct 143 ms 143224 KB Output is correct
91 Correct 161 ms 143352 KB Output is correct
92 Correct 160 ms 143352 KB Output is correct
93 Correct 157 ms 143224 KB Output is correct