답안 #629988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629988 2022-08-15T13:22:06 Z colossal_pepe Collecting Stamps 3 (JOI20_ho_t3) C++17
25 / 100
2000 ms 173200 KB
#include <iostream>
#include <map>
using namespace std;

int n, l, x[205], t[205], late = -1;
map<int, int> dp[205][205];

int dist(int x1, int x2) {
    if (x1 > x2) swap(x1, x2);
    return min(x2 - x1, l - x2 + x1);
}

int solve(int i, int j, int time_passed) {
    if (abs(i - j) == 1) return 0;
    if (dp[i][j].count(time_passed)) return dp[i][j][time_passed];
    int cur = i, l = min(i, j), r = max(i, j);
    int ans = solve(l + 1, r, min(late, dist(x[cur], x[l + 1]) + time_passed)) + (dist(x[cur], x[l + 1]) + time_passed <= t[l + 1]);
    ans = max(ans, solve(r - 1, l, min(late, dist(x[cur], x[r - 1]) + time_passed)) + (dist(x[cur], x[r - 1]) + time_passed <= t[r - 1]));
    dp[i][j][time_passed] = ans;
    return ans;
}

int main() {
    cin >> n >> l;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
        late = max(late, t[i] + 1);
    }
    cout << solve(0, n + 1, 0) << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 1 ms 2260 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 2 ms 2260 KB Output is correct
7 Correct 1 ms 2260 KB Output is correct
8 Correct 2 ms 2260 KB Output is correct
9 Correct 1 ms 2260 KB Output is correct
10 Correct 1 ms 2248 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 2 ms 2260 KB Output is correct
14 Correct 1 ms 2260 KB Output is correct
15 Correct 1 ms 2260 KB Output is correct
16 Correct 1 ms 2260 KB Output is correct
17 Correct 2 ms 2260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 1 ms 2260 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 2 ms 2260 KB Output is correct
7 Correct 1 ms 2260 KB Output is correct
8 Correct 2 ms 2260 KB Output is correct
9 Correct 1 ms 2260 KB Output is correct
10 Correct 1 ms 2248 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 2 ms 2260 KB Output is correct
14 Correct 1 ms 2260 KB Output is correct
15 Correct 1 ms 2260 KB Output is correct
16 Correct 1 ms 2260 KB Output is correct
17 Correct 2 ms 2260 KB Output is correct
18 Correct 1 ms 2260 KB Output is correct
19 Correct 1 ms 2260 KB Output is correct
20 Correct 1 ms 2260 KB Output is correct
21 Correct 1 ms 2260 KB Output is correct
22 Correct 1 ms 2288 KB Output is correct
23 Correct 11 ms 3740 KB Output is correct
24 Correct 2 ms 2260 KB Output is correct
25 Correct 5 ms 2900 KB Output is correct
26 Correct 2 ms 2260 KB Output is correct
27 Correct 2 ms 2260 KB Output is correct
28 Correct 1 ms 2260 KB Output is correct
29 Correct 1 ms 2324 KB Output is correct
30 Correct 1 ms 2260 KB Output is correct
31 Correct 1 ms 2260 KB Output is correct
32 Correct 1 ms 2260 KB Output is correct
33 Correct 1 ms 2388 KB Output is correct
34 Correct 2 ms 2260 KB Output is correct
35 Correct 2 ms 2260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 1 ms 2260 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 2 ms 2260 KB Output is correct
7 Correct 1 ms 2260 KB Output is correct
8 Correct 2 ms 2260 KB Output is correct
9 Correct 1 ms 2260 KB Output is correct
10 Correct 1 ms 2248 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 2 ms 2260 KB Output is correct
14 Correct 1 ms 2260 KB Output is correct
15 Correct 1 ms 2260 KB Output is correct
16 Correct 1 ms 2260 KB Output is correct
17 Correct 2 ms 2260 KB Output is correct
18 Correct 231 ms 33016 KB Output is correct
19 Correct 146 ms 24972 KB Output is correct
20 Correct 46 ms 12020 KB Output is correct
21 Correct 116 ms 21744 KB Output is correct
22 Correct 119 ms 23044 KB Output is correct
23 Correct 92 ms 17732 KB Output is correct
24 Correct 2 ms 2516 KB Output is correct
25 Correct 105 ms 17352 KB Output is correct
26 Correct 2 ms 2388 KB Output is correct
27 Correct 105 ms 17664 KB Output is correct
28 Correct 2 ms 2516 KB Output is correct
29 Correct 89 ms 17840 KB Output is correct
30 Correct 2 ms 2644 KB Output is correct
31 Correct 111 ms 17268 KB Output is correct
32 Correct 4 ms 3156 KB Output is correct
33 Correct 110 ms 17008 KB Output is correct
34 Correct 2 ms 2388 KB Output is correct
35 Correct 75 ms 14232 KB Output is correct
36 Correct 2 ms 2404 KB Output is correct
37 Correct 74 ms 15544 KB Output is correct
38 Correct 13 ms 5224 KB Output is correct
39 Correct 109 ms 17808 KB Output is correct
40 Correct 2 ms 2516 KB Output is correct
41 Correct 255 ms 33628 KB Output is correct
42 Correct 9 ms 4836 KB Output is correct
43 Correct 208 ms 33236 KB Output is correct
44 Correct 9 ms 5204 KB Output is correct
45 Correct 228 ms 33732 KB Output is correct
46 Correct 10 ms 4984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2260 KB Output is correct
2 Correct 1 ms 2260 KB Output is correct
3 Correct 1 ms 2260 KB Output is correct
4 Correct 1 ms 2260 KB Output is correct
5 Correct 1 ms 2260 KB Output is correct
6 Correct 2 ms 2260 KB Output is correct
7 Correct 1 ms 2260 KB Output is correct
8 Correct 2 ms 2260 KB Output is correct
9 Correct 1 ms 2260 KB Output is correct
10 Correct 1 ms 2248 KB Output is correct
11 Correct 1 ms 2260 KB Output is correct
12 Correct 1 ms 2260 KB Output is correct
13 Correct 2 ms 2260 KB Output is correct
14 Correct 1 ms 2260 KB Output is correct
15 Correct 1 ms 2260 KB Output is correct
16 Correct 1 ms 2260 KB Output is correct
17 Correct 2 ms 2260 KB Output is correct
18 Correct 1 ms 2260 KB Output is correct
19 Correct 1 ms 2260 KB Output is correct
20 Correct 1 ms 2260 KB Output is correct
21 Correct 1 ms 2260 KB Output is correct
22 Correct 1 ms 2288 KB Output is correct
23 Correct 11 ms 3740 KB Output is correct
24 Correct 2 ms 2260 KB Output is correct
25 Correct 5 ms 2900 KB Output is correct
26 Correct 2 ms 2260 KB Output is correct
27 Correct 2 ms 2260 KB Output is correct
28 Correct 1 ms 2260 KB Output is correct
29 Correct 1 ms 2324 KB Output is correct
30 Correct 1 ms 2260 KB Output is correct
31 Correct 1 ms 2260 KB Output is correct
32 Correct 1 ms 2260 KB Output is correct
33 Correct 1 ms 2388 KB Output is correct
34 Correct 2 ms 2260 KB Output is correct
35 Correct 2 ms 2260 KB Output is correct
36 Correct 231 ms 33016 KB Output is correct
37 Correct 146 ms 24972 KB Output is correct
38 Correct 46 ms 12020 KB Output is correct
39 Correct 116 ms 21744 KB Output is correct
40 Correct 119 ms 23044 KB Output is correct
41 Correct 92 ms 17732 KB Output is correct
42 Correct 2 ms 2516 KB Output is correct
43 Correct 105 ms 17352 KB Output is correct
44 Correct 2 ms 2388 KB Output is correct
45 Correct 105 ms 17664 KB Output is correct
46 Correct 2 ms 2516 KB Output is correct
47 Correct 89 ms 17840 KB Output is correct
48 Correct 2 ms 2644 KB Output is correct
49 Correct 111 ms 17268 KB Output is correct
50 Correct 4 ms 3156 KB Output is correct
51 Correct 110 ms 17008 KB Output is correct
52 Correct 2 ms 2388 KB Output is correct
53 Correct 75 ms 14232 KB Output is correct
54 Correct 2 ms 2404 KB Output is correct
55 Correct 74 ms 15544 KB Output is correct
56 Correct 13 ms 5224 KB Output is correct
57 Correct 109 ms 17808 KB Output is correct
58 Correct 2 ms 2516 KB Output is correct
59 Correct 255 ms 33628 KB Output is correct
60 Correct 9 ms 4836 KB Output is correct
61 Correct 208 ms 33236 KB Output is correct
62 Correct 9 ms 5204 KB Output is correct
63 Correct 228 ms 33732 KB Output is correct
64 Correct 10 ms 4984 KB Output is correct
65 Execution timed out 2049 ms 173200 KB Time limit exceeded
66 Halted 0 ms 0 KB -