답안 #647470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
647470 2022-10-02T16:48:11 Z Astrayt Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
79 ms 66388 KB
//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second

template<typename T> void chmin(T &a, T b){if(a > b) a = b;}
template<typename T> void chmax(T &a, T b){if(a < b) a = b;}

int dp[205][205][205][2];

void solve(){
    int N, L, ans = 0; cin >> N >> L;
    vector<int> X(N + 2, 0), T(N + 2, 0);
    for(int i = 1; i <= N; ++i) cin >> X[i];
    for(int i = 1; i <= N; ++i) cin >> T[i];
    X[N + 1] = L;
    for(int i = 0; i <= N; ++i){
        for(int j = 0; i + j <= N; ++j){
            for(int k = 0; k <= N; ++k){
                dp[i][j][k][0] = dp[i][j][k][1] = (1ll<<60);
            }
        }
    }
    dp[0][0][0][0] = dp[0][0][0][1] = 0;
    for(int i = 0; i <= N; ++i){
        for(int j = 0; i + j <= N; ++j){
            for(int k = 0; k <= i + j; ++k){
                int t1 = X[N - j + 1] - X[N - j], t2 = X[i] + L - X[N - j];
                chmin(dp[i][j + 1][k + (dp[i][j][k][1] + t1 <= T[N - j])][1], dp[i][j][k][1] + t1);
                chmin(dp[i][j + 1][k + (dp[i][j][k][0] + t2 <= T[N - j])][1], dp[i][j][k][0] + t2);
                t1 = X[i + 1] - X[i], t2 = L - X[N - j + 1] + X[i + 1];
                chmin(dp[i + 1][j][k + (dp[i][j][k][0] + t1 <= T[i + 1])][0], dp[i][j][k][0] + t1);
                chmin(dp[i + 1][j][k + (dp[i][j][k][1] + t2 <= T[i + 1])][0], dp[i][j][k][1] + t2);
            }
        }
    }
    for(int i = 0; i <= N; ++i){
        for(int j = 0; i + j <= N; ++j){
            for(int k = 0; k <= i + j; ++k){
                if(dp[i][j][k][0] < (1ll<<60)) chmax(ans, k);
                if(dp[i][j][k][1] < (1ll<<60)) chmax(ans, k);
            }
        }
    }
    cout << ans << '\n';
}

signed main(){
    starburst
    int t = 1; //cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 452 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 452 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 1 ms 456 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 1 ms 584 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 584 KB Output is correct
25 Correct 1 ms 712 KB Output is correct
26 Correct 1 ms 712 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 716 KB Output is correct
35 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 452 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 49 ms 53332 KB Output is correct
19 Correct 32 ms 32492 KB Output is correct
20 Correct 15 ms 17492 KB Output is correct
21 Correct 27 ms 30712 KB Output is correct
22 Correct 35 ms 39728 KB Output is correct
23 Correct 13 ms 14956 KB Output is correct
24 Correct 7 ms 11720 KB Output is correct
25 Correct 11 ms 14548 KB Output is correct
26 Correct 4 ms 5716 KB Output is correct
27 Correct 13 ms 15196 KB Output is correct
28 Correct 8 ms 10952 KB Output is correct
29 Correct 12 ms 15444 KB Output is correct
30 Correct 8 ms 12248 KB Output is correct
31 Correct 11 ms 14548 KB Output is correct
32 Correct 5 ms 7764 KB Output is correct
33 Correct 11 ms 14548 KB Output is correct
34 Correct 3 ms 5332 KB Output is correct
35 Correct 10 ms 14280 KB Output is correct
36 Correct 4 ms 6868 KB Output is correct
37 Correct 11 ms 15188 KB Output is correct
38 Correct 5 ms 8404 KB Output is correct
39 Correct 12 ms 15828 KB Output is correct
40 Correct 6 ms 9428 KB Output is correct
41 Correct 61 ms 65720 KB Output is correct
42 Correct 39 ms 44400 KB Output is correct
43 Correct 67 ms 65724 KB Output is correct
44 Correct 32 ms 43860 KB Output is correct
45 Correct 67 ms 65612 KB Output is correct
46 Correct 33 ms 44416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 452 KB Output is correct
16 Correct 1 ms 596 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 1 ms 456 KB Output is correct
20 Correct 1 ms 596 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 1 ms 584 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 584 KB Output is correct
25 Correct 1 ms 712 KB Output is correct
26 Correct 1 ms 712 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 1 ms 724 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 716 KB Output is correct
35 Correct 1 ms 724 KB Output is correct
36 Correct 49 ms 53332 KB Output is correct
37 Correct 32 ms 32492 KB Output is correct
38 Correct 15 ms 17492 KB Output is correct
39 Correct 27 ms 30712 KB Output is correct
40 Correct 35 ms 39728 KB Output is correct
41 Correct 13 ms 14956 KB Output is correct
42 Correct 7 ms 11720 KB Output is correct
43 Correct 11 ms 14548 KB Output is correct
44 Correct 4 ms 5716 KB Output is correct
45 Correct 13 ms 15196 KB Output is correct
46 Correct 8 ms 10952 KB Output is correct
47 Correct 12 ms 15444 KB Output is correct
48 Correct 8 ms 12248 KB Output is correct
49 Correct 11 ms 14548 KB Output is correct
50 Correct 5 ms 7764 KB Output is correct
51 Correct 11 ms 14548 KB Output is correct
52 Correct 3 ms 5332 KB Output is correct
53 Correct 10 ms 14280 KB Output is correct
54 Correct 4 ms 6868 KB Output is correct
55 Correct 11 ms 15188 KB Output is correct
56 Correct 5 ms 8404 KB Output is correct
57 Correct 12 ms 15828 KB Output is correct
58 Correct 6 ms 9428 KB Output is correct
59 Correct 61 ms 65720 KB Output is correct
60 Correct 39 ms 44400 KB Output is correct
61 Correct 67 ms 65724 KB Output is correct
62 Correct 32 ms 43860 KB Output is correct
63 Correct 67 ms 65612 KB Output is correct
64 Correct 33 ms 44416 KB Output is correct
65 Correct 59 ms 59384 KB Output is correct
66 Correct 51 ms 54544 KB Output is correct
67 Correct 49 ms 52196 KB Output is correct
68 Correct 45 ms 48304 KB Output is correct
69 Correct 54 ms 58708 KB Output is correct
70 Correct 54 ms 56324 KB Output is correct
71 Correct 55 ms 56908 KB Output is correct
72 Correct 61 ms 57444 KB Output is correct
73 Correct 43 ms 53424 KB Output is correct
74 Correct 45 ms 49876 KB Output is correct
75 Correct 48 ms 55120 KB Output is correct
76 Correct 64 ms 63148 KB Output is correct
77 Correct 55 ms 63176 KB Output is correct
78 Correct 44 ms 48920 KB Output is correct
79 Correct 44 ms 50488 KB Output is correct
80 Correct 65 ms 61804 KB Output is correct
81 Correct 50 ms 51036 KB Output is correct
82 Correct 45 ms 54048 KB Output is correct
83 Correct 63 ms 65728 KB Output is correct
84 Correct 53 ms 56348 KB Output is correct
85 Correct 59 ms 61256 KB Output is correct
86 Correct 59 ms 60016 KB Output is correct
87 Correct 54 ms 55064 KB Output is correct
88 Correct 73 ms 66388 KB Output is correct
89 Correct 72 ms 66272 KB Output is correct
90 Correct 46 ms 55728 KB Output is correct
91 Correct 79 ms 66380 KB Output is correct
92 Correct 70 ms 66388 KB Output is correct
93 Correct 55 ms 64980 KB Output is correct