Submission #220182

# Submission time Handle Problem Language Result Execution time Memory
220182 2020-04-07T08:33:40 Z IldarKA Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
135 ms 127480 KB
#include <bits/stdc++.h>

using namespace std;
int n;
long long l, x[202], t[202], dp[202][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 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 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 544 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 6 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 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 544 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 6 ms 896 KB Output is correct
18 Correct 5 ms 1024 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
20 Correct 5 ms 896 KB Output is correct
21 Correct 5 ms 1152 KB Output is correct
22 Correct 5 ms 640 KB Output is correct
23 Correct 5 ms 1152 KB Output is correct
24 Correct 5 ms 1024 KB Output is correct
25 Correct 5 ms 1024 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 640 KB Output is correct
29 Correct 5 ms 1152 KB Output is correct
30 Correct 5 ms 1152 KB Output is correct
31 Correct 5 ms 1024 KB Output is correct
32 Correct 5 ms 1024 KB Output is correct
33 Correct 5 ms 1152 KB Output is correct
34 Correct 5 ms 1152 KB Output is correct
35 Correct 5 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 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 544 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 6 ms 896 KB Output is correct
18 Correct 105 ms 102904 KB Output is correct
19 Correct 67 ms 62456 KB Output is correct
20 Correct 31 ms 33408 KB Output is correct
21 Correct 55 ms 59008 KB Output is correct
22 Correct 74 ms 76408 KB Output is correct
23 Correct 28 ms 28416 KB Output is correct
24 Correct 20 ms 22272 KB Output is correct
25 Correct 27 ms 27776 KB Output is correct
26 Correct 10 ms 10624 KB Output is correct
27 Correct 29 ms 29052 KB Output is correct
28 Correct 21 ms 20864 KB Output is correct
29 Correct 28 ms 29696 KB Output is correct
30 Correct 20 ms 23296 KB Output is correct
31 Correct 26 ms 27776 KB Output is correct
32 Correct 14 ms 14592 KB Output is correct
33 Correct 26 ms 27904 KB Output is correct
34 Correct 10 ms 9984 KB Output is correct
35 Correct 23 ms 27264 KB Output is correct
36 Correct 12 ms 13056 KB Output is correct
37 Correct 25 ms 29056 KB Output is correct
38 Correct 15 ms 16000 KB Output is correct
39 Correct 26 ms 30208 KB Output is correct
40 Correct 16 ms 17792 KB Output is correct
41 Correct 135 ms 126840 KB Output is correct
42 Correct 63 ms 85496 KB Output is correct
43 Correct 130 ms 126828 KB Output is correct
44 Correct 62 ms 84480 KB Output is correct
45 Correct 131 ms 126840 KB Output is correct
46 Correct 62 ms 85624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 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 544 KB Output is correct
15 Correct 5 ms 640 KB Output is correct
16 Correct 5 ms 896 KB Output is correct
17 Correct 6 ms 896 KB Output is correct
18 Correct 5 ms 1024 KB Output is correct
19 Correct 5 ms 768 KB Output is correct
20 Correct 5 ms 896 KB Output is correct
21 Correct 5 ms 1152 KB Output is correct
22 Correct 5 ms 640 KB Output is correct
23 Correct 5 ms 1152 KB Output is correct
24 Correct 5 ms 1024 KB Output is correct
25 Correct 5 ms 1024 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 640 KB Output is correct
29 Correct 5 ms 1152 KB Output is correct
30 Correct 5 ms 1152 KB Output is correct
31 Correct 5 ms 1024 KB Output is correct
32 Correct 5 ms 1024 KB Output is correct
33 Correct 5 ms 1152 KB Output is correct
34 Correct 5 ms 1152 KB Output is correct
35 Correct 5 ms 1152 KB Output is correct
36 Correct 105 ms 102904 KB Output is correct
37 Correct 67 ms 62456 KB Output is correct
38 Correct 31 ms 33408 KB Output is correct
39 Correct 55 ms 59008 KB Output is correct
40 Correct 74 ms 76408 KB Output is correct
41 Correct 28 ms 28416 KB Output is correct
42 Correct 20 ms 22272 KB Output is correct
43 Correct 27 ms 27776 KB Output is correct
44 Correct 10 ms 10624 KB Output is correct
45 Correct 29 ms 29052 KB Output is correct
46 Correct 21 ms 20864 KB Output is correct
47 Correct 28 ms 29696 KB Output is correct
48 Correct 20 ms 23296 KB Output is correct
49 Correct 26 ms 27776 KB Output is correct
50 Correct 14 ms 14592 KB Output is correct
51 Correct 26 ms 27904 KB Output is correct
52 Correct 10 ms 9984 KB Output is correct
53 Correct 23 ms 27264 KB Output is correct
54 Correct 12 ms 13056 KB Output is correct
55 Correct 25 ms 29056 KB Output is correct
56 Correct 15 ms 16000 KB Output is correct
57 Correct 26 ms 30208 KB Output is correct
58 Correct 16 ms 17792 KB Output is correct
59 Correct 135 ms 126840 KB Output is correct
60 Correct 63 ms 85496 KB Output is correct
61 Correct 130 ms 126828 KB Output is correct
62 Correct 62 ms 84480 KB Output is correct
63 Correct 131 ms 126840 KB Output is correct
64 Correct 62 ms 85624 KB Output is correct
65 Correct 83 ms 114680 KB Output is correct
66 Correct 80 ms 105208 KB Output is correct
67 Correct 76 ms 100776 KB Output is correct
68 Correct 70 ms 93052 KB Output is correct
69 Correct 85 ms 113400 KB Output is correct
70 Correct 84 ms 108664 KB Output is correct
71 Correct 79 ms 109816 KB Output is correct
72 Correct 90 ms 111096 KB Output is correct
73 Correct 75 ms 102904 KB Output is correct
74 Correct 75 ms 96248 KB Output is correct
75 Correct 76 ms 106360 KB Output is correct
76 Correct 104 ms 121976 KB Output is correct
77 Correct 90 ms 122068 KB Output is correct
78 Correct 78 ms 94072 KB Output is correct
79 Correct 73 ms 97400 KB Output is correct
80 Correct 103 ms 119544 KB Output is correct
81 Correct 72 ms 98424 KB Output is correct
82 Correct 90 ms 104184 KB Output is correct
83 Correct 89 ms 126840 KB Output is correct
84 Correct 86 ms 108792 KB Output is correct
85 Correct 91 ms 118264 KB Output is correct
86 Correct 90 ms 115832 KB Output is correct
87 Correct 83 ms 106360 KB Output is correct
88 Correct 104 ms 127480 KB Output is correct
89 Correct 91 ms 127480 KB Output is correct
90 Correct 74 ms 107640 KB Output is correct
91 Correct 98 ms 127480 KB Output is correct
92 Correct 98 ms 127472 KB Output is correct
93 Correct 88 ms 125688 KB Output is correct