Submission #220181

# Submission time Handle Problem Language Result Execution time Memory
220181 2020-04-07T08:26:27 Z IldarKA Collecting Stamps 3 (JOI20_ho_t3) C++17
25 / 100
108 ms 128632 KB
#include <bits/stdc++.h>

using namespace std;
int n, l, x[202], t[202], dp[201][201][201][2];
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];
    }
    for(int i = 1; i <= n + 1; i++){
        for(int j = 0; j <= n; j++){
            for(int t = 0; t <= n; t++){
                dp[i][j][t][0] = 1e9 + 1;
                dp[i][j][t][1] = 1e9 + 1;
            }
        }
    }
    x[n + 1] = l;
    dp[n + 1][0][0][0] = 0;
    dp[n + 1][0][0][1] = 0;
    for(int i = n + 1; i >= 1; i--){
        for(int j = 0; j <= n; j++){
            for(int o = 0; o <= min((n + 1) - i + j, n); o++){
                if(dp[i][j][o][0] < 1e9){
                    if(i - 1 > j && x[j] + (l - x[i - 1]) <= 1e9){
                        dp[i - 1][j][o + (x[j] + (l - x[i - 1]) + dp[i][j][o][0] <= t[i - 1])][1] = min(dp[i - 1][j][o + (x[j] + (l - x[i - 1]) + dp[i][j][o][0] <= t[i - 1])][1], x[j] + (l - x[i - 1]) + dp[i][j][o][0]);
                    }
                    if(j + 1 < i){
                        dp[i][j + 1][o + (x[j + 1] - x[j] + dp[i][j][o][0] <= t[j + 1])][0] = min(x[j + 1] - x[j] + dp[i][j][o][0], dp[i][j + 1][o + (x[j + 1] - x[j] + dp[i][j][o][0] <= t[j + 1])][0]);
                    }
                }
                if(dp[i][j][o][1] < 1e9){
                    if(i - 1 > j){
                        dp[i - 1][j][o + ((x[i] - x[i - 1]) + dp[i][j][o][1] <= t[i - 1])][1] = min(dp[i - 1][j][o + ((x[i] - x[i - 1]) + dp[i][j][o][1] <= t[i - 1])][1], (x[i] - x[i - 1]) + dp[i][j][o][1]);
                    }
                    if(j + 1 < i && (l - x[i]) + x[j + 1] <= 1e9){
                        dp[i][j + 1][o + ((l - x[i]) + x[j + 1] + dp[i][j][o][1] <= t[j + 1])][0] = min((l - x[i]) + x[j + 1] + dp[i][j][o][1], dp[i][j + 1][o + ((l - x[i]) + x[j + 1] + dp[i][j][o][1] <= t[j + 1])][0]);
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i = n + 1; i >= 1; i--){
        for(int j = 0; j <= n; j++){
            for(int o = 0; o <= min((n + 1) - i + j, n); o++){
                if(dp[i][j][o][0] != 1e9 + 1 || dp[i][j][o][1] != 1e9 + 1){
                    //cout << i << " " << j << " " << o << " " << dp[i][j][o][0] << " " << dp[i][j][o][1] << '\n';
                    ans = max(o, ans);
                }
            }
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 640 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 640 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
18 Correct 5 ms 768 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 636 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 5 ms 768 KB Output is correct
24 Correct 5 ms 640 KB Output is correct
25 Correct 5 ms 768 KB Output is correct
26 Correct 5 ms 768 KB Output is correct
27 Correct 4 ms 512 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 768 KB Output is correct
30 Correct 5 ms 768 KB Output is correct
31 Correct 5 ms 768 KB Output is correct
32 Correct 5 ms 640 KB Output is correct
33 Correct 5 ms 768 KB Output is correct
34 Correct 5 ms 768 KB Output is correct
35 Correct 6 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 640 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
18 Correct 75 ms 51960 KB Output is correct
19 Correct 44 ms 31744 KB Output is correct
20 Correct 22 ms 17024 KB Output is correct
21 Correct 39 ms 29952 KB Output is correct
22 Correct 55 ms 38656 KB Output is correct
23 Correct 20 ms 14592 KB Output is correct
24 Correct 14 ms 11392 KB Output is correct
25 Correct 20 ms 14208 KB Output is correct
26 Correct 8 ms 5632 KB Output is correct
27 Correct 21 ms 14848 KB Output is correct
28 Correct 14 ms 10624 KB Output is correct
29 Correct 20 ms 15104 KB Output is correct
30 Correct 15 ms 12032 KB Output is correct
31 Correct 20 ms 14208 KB Output is correct
32 Correct 11 ms 7680 KB Output is correct
33 Correct 19 ms 14208 KB Output is correct
34 Correct 8 ms 5248 KB Output is correct
35 Correct 16 ms 13952 KB Output is correct
36 Correct 9 ms 6784 KB Output is correct
37 Correct 17 ms 14848 KB Output is correct
38 Correct 11 ms 8320 KB Output is correct
39 Correct 18 ms 15488 KB Output is correct
40 Correct 12 ms 9216 KB Output is correct
41 Correct 106 ms 63608 KB Output is correct
42 Correct 42 ms 43264 KB Output is correct
43 Correct 105 ms 63608 KB Output is correct
44 Correct 40 ms 42752 KB Output is correct
45 Correct 108 ms 63736 KB Output is correct
46 Correct 41 ms 43264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 640 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
18 Correct 5 ms 768 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 636 KB Output is correct
21 Correct 5 ms 768 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 5 ms 768 KB Output is correct
24 Correct 5 ms 640 KB Output is correct
25 Correct 5 ms 768 KB Output is correct
26 Correct 5 ms 768 KB Output is correct
27 Correct 4 ms 512 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 768 KB Output is correct
30 Correct 5 ms 768 KB Output is correct
31 Correct 5 ms 768 KB Output is correct
32 Correct 5 ms 640 KB Output is correct
33 Correct 5 ms 768 KB Output is correct
34 Correct 5 ms 768 KB Output is correct
35 Correct 6 ms 768 KB Output is correct
36 Correct 75 ms 51960 KB Output is correct
37 Correct 44 ms 31744 KB Output is correct
38 Correct 22 ms 17024 KB Output is correct
39 Correct 39 ms 29952 KB Output is correct
40 Correct 55 ms 38656 KB Output is correct
41 Correct 20 ms 14592 KB Output is correct
42 Correct 14 ms 11392 KB Output is correct
43 Correct 20 ms 14208 KB Output is correct
44 Correct 8 ms 5632 KB Output is correct
45 Correct 21 ms 14848 KB Output is correct
46 Correct 14 ms 10624 KB Output is correct
47 Correct 20 ms 15104 KB Output is correct
48 Correct 15 ms 12032 KB Output is correct
49 Correct 20 ms 14208 KB Output is correct
50 Correct 11 ms 7680 KB Output is correct
51 Correct 19 ms 14208 KB Output is correct
52 Correct 8 ms 5248 KB Output is correct
53 Correct 16 ms 13952 KB Output is correct
54 Correct 9 ms 6784 KB Output is correct
55 Correct 17 ms 14848 KB Output is correct
56 Correct 11 ms 8320 KB Output is correct
57 Correct 18 ms 15488 KB Output is correct
58 Correct 12 ms 9216 KB Output is correct
59 Correct 106 ms 63608 KB Output is correct
60 Correct 42 ms 43264 KB Output is correct
61 Correct 105 ms 63608 KB Output is correct
62 Correct 40 ms 42752 KB Output is correct
63 Correct 108 ms 63736 KB Output is correct
64 Correct 41 ms 43264 KB Output is correct
65 Correct 61 ms 57848 KB Output is correct
66 Correct 55 ms 53116 KB Output is correct
67 Correct 51 ms 50816 KB Output is correct
68 Correct 48 ms 46976 KB Output is correct
69 Correct 61 ms 57216 KB Output is correct
70 Correct 60 ms 54912 KB Output is correct
71 Correct 56 ms 55456 KB Output is correct
72 Correct 58 ms 56064 KB Output is correct
73 Correct 52 ms 51968 KB Output is correct
74 Correct 53 ms 48632 KB Output is correct
75 Correct 53 ms 53760 KB Output is correct
76 Correct 77 ms 61688 KB Output is correct
77 Correct 61 ms 61560 KB Output is correct
78 Correct 56 ms 47488 KB Output is correct
79 Correct 50 ms 49272 KB Output is correct
80 Correct 76 ms 60280 KB Output is correct
81 Correct 49 ms 49792 KB Output is correct
82 Correct 58 ms 52608 KB Output is correct
83 Correct 63 ms 63608 KB Output is correct
84 Correct 61 ms 54912 KB Output is correct
85 Correct 64 ms 59916 KB Output is correct
86 Correct 68 ms 58548 KB Output is correct
87 Correct 54 ms 53760 KB Output is correct
88 Runtime error 107 ms 128632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
89 Halted 0 ms 0 KB -