답안 #489585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
489585 2021-11-23T10:07:45 Z Jarif_Rahman Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
132 ms 126280 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
ll dp[200][200][2][201];
const ll inf = 1e9+7;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    for(int i = 0; i < 200; i++) for(int j = 0; j < 200; j++) for(int k = 0; k <= 200; k++){
        dp[i][j][0][k] = -inf;
        dp[i][j][1][k] = -inf;
    }

    int n; ll L; cin >> n >> L;

    vector<ll> dis(n), tm(n);
    for(ll &x: dis) cin >> x;
    for(ll &x: tm) cin >> x;

    for(int i = 0; i < n; i++){
        dp[i][i][0][1] = tm[i];
        dp[i][i][1][1] = tm[i];
    }

    for(int rr = 2; rr <= n; rr++) for(int l = 0; l+rr-1 < n; l++){
        int r = l+rr-1;

        vector<ll> cur0(n+1), cur1(n+1);
        
        // left -> right
        for(int i = 1; i <= n; i++) cur0[i] = dp[l+1][r][0][i]-(dis[l+1]-dis[l]);
        for(int i = 1; i <= n; i++){
            if(tm[l] > cur0[i]){
                for(int j = n; j > i; j--) cur0[j] = cur0[j-1];
                cur0[i] = tm[l];
                break;
            }
        }

        // left -> left
        for(int i = 1; i <= n; i++) cur1[i] = dp[l+1][r][1][i]-(dis[l]+L-dis[r]);
        for(int i = 1; i <= n; i++){
            if(tm[l] > cur1[i]){
                for(int j = n; j > i; j--) cur1[j] = cur1[j-1];
                cur1[i] = tm[l];
                break;
            }
        }


        // left
        for(int i = 1; i <= n; i++) dp[l][r][0][i] = max(cur0[i], cur1[i]);

        // right -> right
        for(int i = 1; i <= n; i++) cur1[i] = dp[l][r-1][0][i]-(L-dis[r]+dis[l]);
        for(int i = 1; i <= n; i++){
            if(tm[r] > cur1[i]){
                for(int j = n; j > i; j--) cur1[j] = cur1[j-1];
                cur1[i] = tm[r];
                break;
            }
        }

        // right -> left
        for(int i = 1; i <= n; i++) cur0[i] = dp[l][r-1][1][i]-(dis[r]-dis[r-1]);
        for(int i = 1; i <= n; i++){
            if(tm[r] > cur0[i]){
                for(int j = n; j > i; j--) cur0[j] = cur0[j-1];
                cur0[i] = tm[r];
                break;
            }
        }

        // right
        for(int i = 1; i <= n; i++) dp[l][r][1][i] = max(cur0[i], cur1[i]);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(dp[0][n-1][0][i] >= dis[0] || dp[0][n-1][1][i] >= L-dis[n-1]) ans = i;
    }
    cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 126116 KB Output is correct
2 Correct 61 ms 126052 KB Output is correct
3 Correct 56 ms 126136 KB Output is correct
4 Correct 58 ms 126160 KB Output is correct
5 Correct 61 ms 126148 KB Output is correct
6 Correct 57 ms 126084 KB Output is correct
7 Correct 58 ms 126076 KB Output is correct
8 Correct 59 ms 126044 KB Output is correct
9 Correct 57 ms 126148 KB Output is correct
10 Correct 56 ms 126080 KB Output is correct
11 Correct 57 ms 126108 KB Output is correct
12 Correct 56 ms 126088 KB Output is correct
13 Correct 57 ms 126156 KB Output is correct
14 Correct 55 ms 126048 KB Output is correct
15 Correct 60 ms 126128 KB Output is correct
16 Correct 61 ms 126068 KB Output is correct
17 Correct 60 ms 126040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 126116 KB Output is correct
2 Correct 61 ms 126052 KB Output is correct
3 Correct 56 ms 126136 KB Output is correct
4 Correct 58 ms 126160 KB Output is correct
5 Correct 61 ms 126148 KB Output is correct
6 Correct 57 ms 126084 KB Output is correct
7 Correct 58 ms 126076 KB Output is correct
8 Correct 59 ms 126044 KB Output is correct
9 Correct 57 ms 126148 KB Output is correct
10 Correct 56 ms 126080 KB Output is correct
11 Correct 57 ms 126108 KB Output is correct
12 Correct 56 ms 126088 KB Output is correct
13 Correct 57 ms 126156 KB Output is correct
14 Correct 55 ms 126048 KB Output is correct
15 Correct 60 ms 126128 KB Output is correct
16 Correct 61 ms 126068 KB Output is correct
17 Correct 60 ms 126040 KB Output is correct
18 Correct 58 ms 126084 KB Output is correct
19 Correct 65 ms 126080 KB Output is correct
20 Correct 56 ms 126148 KB Output is correct
21 Correct 61 ms 126164 KB Output is correct
22 Correct 75 ms 126076 KB Output is correct
23 Correct 60 ms 126112 KB Output is correct
24 Correct 60 ms 126148 KB Output is correct
25 Correct 61 ms 126148 KB Output is correct
26 Correct 57 ms 126112 KB Output is correct
27 Correct 69 ms 126164 KB Output is correct
28 Correct 56 ms 126136 KB Output is correct
29 Correct 55 ms 126084 KB Output is correct
30 Correct 58 ms 126144 KB Output is correct
31 Correct 57 ms 126148 KB Output is correct
32 Correct 68 ms 126072 KB Output is correct
33 Correct 70 ms 126044 KB Output is correct
34 Correct 57 ms 126148 KB Output is correct
35 Correct 58 ms 126164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 126116 KB Output is correct
2 Correct 61 ms 126052 KB Output is correct
3 Correct 56 ms 126136 KB Output is correct
4 Correct 58 ms 126160 KB Output is correct
5 Correct 61 ms 126148 KB Output is correct
6 Correct 57 ms 126084 KB Output is correct
7 Correct 58 ms 126076 KB Output is correct
8 Correct 59 ms 126044 KB Output is correct
9 Correct 57 ms 126148 KB Output is correct
10 Correct 56 ms 126080 KB Output is correct
11 Correct 57 ms 126108 KB Output is correct
12 Correct 56 ms 126088 KB Output is correct
13 Correct 57 ms 126156 KB Output is correct
14 Correct 55 ms 126048 KB Output is correct
15 Correct 60 ms 126128 KB Output is correct
16 Correct 61 ms 126068 KB Output is correct
17 Correct 60 ms 126040 KB Output is correct
18 Correct 95 ms 126268 KB Output is correct
19 Correct 78 ms 126164 KB Output is correct
20 Correct 73 ms 126192 KB Output is correct
21 Correct 70 ms 126056 KB Output is correct
22 Correct 84 ms 126192 KB Output is correct
23 Correct 62 ms 126148 KB Output is correct
24 Correct 61 ms 126076 KB Output is correct
25 Correct 64 ms 126168 KB Output is correct
26 Correct 57 ms 126060 KB Output is correct
27 Correct 61 ms 126144 KB Output is correct
28 Correct 62 ms 126076 KB Output is correct
29 Correct 63 ms 126144 KB Output is correct
30 Correct 67 ms 126160 KB Output is correct
31 Correct 67 ms 126132 KB Output is correct
32 Correct 61 ms 126152 KB Output is correct
33 Correct 62 ms 126152 KB Output is correct
34 Correct 59 ms 126056 KB Output is correct
35 Correct 65 ms 126056 KB Output is correct
36 Correct 69 ms 126152 KB Output is correct
37 Correct 62 ms 126152 KB Output is correct
38 Correct 67 ms 126104 KB Output is correct
39 Correct 73 ms 126172 KB Output is correct
40 Correct 65 ms 126068 KB Output is correct
41 Correct 108 ms 126280 KB Output is correct
42 Correct 91 ms 126152 KB Output is correct
43 Correct 132 ms 126068 KB Output is correct
44 Correct 84 ms 126168 KB Output is correct
45 Correct 105 ms 126168 KB Output is correct
46 Correct 96 ms 126176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 126116 KB Output is correct
2 Correct 61 ms 126052 KB Output is correct
3 Correct 56 ms 126136 KB Output is correct
4 Correct 58 ms 126160 KB Output is correct
5 Correct 61 ms 126148 KB Output is correct
6 Correct 57 ms 126084 KB Output is correct
7 Correct 58 ms 126076 KB Output is correct
8 Correct 59 ms 126044 KB Output is correct
9 Correct 57 ms 126148 KB Output is correct
10 Correct 56 ms 126080 KB Output is correct
11 Correct 57 ms 126108 KB Output is correct
12 Correct 56 ms 126088 KB Output is correct
13 Correct 57 ms 126156 KB Output is correct
14 Correct 55 ms 126048 KB Output is correct
15 Correct 60 ms 126128 KB Output is correct
16 Correct 61 ms 126068 KB Output is correct
17 Correct 60 ms 126040 KB Output is correct
18 Correct 58 ms 126084 KB Output is correct
19 Correct 65 ms 126080 KB Output is correct
20 Correct 56 ms 126148 KB Output is correct
21 Correct 61 ms 126164 KB Output is correct
22 Correct 75 ms 126076 KB Output is correct
23 Correct 60 ms 126112 KB Output is correct
24 Correct 60 ms 126148 KB Output is correct
25 Correct 61 ms 126148 KB Output is correct
26 Correct 57 ms 126112 KB Output is correct
27 Correct 69 ms 126164 KB Output is correct
28 Correct 56 ms 126136 KB Output is correct
29 Correct 55 ms 126084 KB Output is correct
30 Correct 58 ms 126144 KB Output is correct
31 Correct 57 ms 126148 KB Output is correct
32 Correct 68 ms 126072 KB Output is correct
33 Correct 70 ms 126044 KB Output is correct
34 Correct 57 ms 126148 KB Output is correct
35 Correct 58 ms 126164 KB Output is correct
36 Correct 95 ms 126268 KB Output is correct
37 Correct 78 ms 126164 KB Output is correct
38 Correct 73 ms 126192 KB Output is correct
39 Correct 70 ms 126056 KB Output is correct
40 Correct 84 ms 126192 KB Output is correct
41 Correct 62 ms 126148 KB Output is correct
42 Correct 61 ms 126076 KB Output is correct
43 Correct 64 ms 126168 KB Output is correct
44 Correct 57 ms 126060 KB Output is correct
45 Correct 61 ms 126144 KB Output is correct
46 Correct 62 ms 126076 KB Output is correct
47 Correct 63 ms 126144 KB Output is correct
48 Correct 67 ms 126160 KB Output is correct
49 Correct 67 ms 126132 KB Output is correct
50 Correct 61 ms 126152 KB Output is correct
51 Correct 62 ms 126152 KB Output is correct
52 Correct 59 ms 126056 KB Output is correct
53 Correct 65 ms 126056 KB Output is correct
54 Correct 69 ms 126152 KB Output is correct
55 Correct 62 ms 126152 KB Output is correct
56 Correct 67 ms 126104 KB Output is correct
57 Correct 73 ms 126172 KB Output is correct
58 Correct 65 ms 126068 KB Output is correct
59 Correct 108 ms 126280 KB Output is correct
60 Correct 91 ms 126152 KB Output is correct
61 Correct 132 ms 126068 KB Output is correct
62 Correct 84 ms 126168 KB Output is correct
63 Correct 105 ms 126168 KB Output is correct
64 Correct 96 ms 126176 KB Output is correct
65 Correct 111 ms 126068 KB Output is correct
66 Correct 91 ms 126168 KB Output is correct
67 Correct 89 ms 126180 KB Output is correct
68 Correct 89 ms 126092 KB Output is correct
69 Correct 109 ms 126240 KB Output is correct
70 Correct 93 ms 126124 KB Output is correct
71 Correct 111 ms 126060 KB Output is correct
72 Correct 97 ms 126152 KB Output is correct
73 Correct 109 ms 126172 KB Output is correct
74 Correct 92 ms 126092 KB Output is correct
75 Correct 100 ms 126152 KB Output is correct
76 Correct 108 ms 126084 KB Output is correct
77 Correct 101 ms 126180 KB Output is correct
78 Correct 99 ms 126064 KB Output is correct
79 Correct 100 ms 126060 KB Output is correct
80 Correct 106 ms 126140 KB Output is correct
81 Correct 89 ms 126156 KB Output is correct
82 Correct 91 ms 126172 KB Output is correct
83 Correct 118 ms 126176 KB Output is correct
84 Correct 99 ms 126076 KB Output is correct
85 Correct 100 ms 126164 KB Output is correct
86 Correct 100 ms 126084 KB Output is correct
87 Correct 102 ms 126172 KB Output is correct
88 Correct 111 ms 126248 KB Output is correct
89 Correct 107 ms 126060 KB Output is correct
90 Correct 94 ms 126140 KB Output is correct
91 Correct 108 ms 126156 KB Output is correct
92 Correct 105 ms 126156 KB Output is correct
93 Correct 115 ms 126164 KB Output is correct