답안 #1018432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018432 2024-07-10T04:03:17 Z snpmrnhlol Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
43 ms 50616 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 200;
const int inf = 1e9 + 10;
int v[N];
int v2[N];
int dp[N + 3][N + 3][N + 3][2];
int main(){
    int n,nr;
    int ans = 0;
    cin>>n>>nr;
    v[0] = 0;
    v2[0] = 100;
    for(int i = 1;i <= n;i++){
        cin>>v[i];
    }
    for(int i = 1;i <= n;i++){
        cin>>v2[i];
    }
    v[n + 1] = nr;
    v2[n + 1] = 100;
    n+=2;
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= i;j++){
            for(int k = 0;k <= i;k++){
                for(int p = 0;p <= 1;p++){
                    if(i == 0 && j == 0 && k == 0 && p == 0){
                        dp[i][j][k][p] = 0;
                    }else{
                        dp[i][j][k][p] = inf;
                        int leftid = n - 1 - (i - j);
                        int rightid = j;
                        int dist = v[rightid] + (nr - v[leftid]);
                        if(i == 0 || leftid <= rightid)continue;
                        if(p == 0){
                            if(leftid == n - 1)continue;
                            ///to leftside
                            ///from rightside
                            if(k != 0 && dist + dp[i - 1][j][k - 1][1] <= v2[leftid]){
                                dp[i][j][k][p] = min(dp[i][j][k][p],dist + dp[i - 1][j][k - 1][1]);
                            }else{
                                if(i != k)dp[i][j][k][p] = min(dp[i][j][k][p],dist + dp[i - 1][j][k][1]);
                            }
                            ///from leftside
                            if(k != 0 && dp[i - 1][j][k - 1][0] + v[leftid + 1] - v[leftid] <= v2[leftid]){
                                dp[i][j][k][p] = min(dp[i][j][k][p],dp[i - 1][j][k - 1][0] + v[leftid + 1] - v[leftid]);
                            }else{
                                if(i != k)dp[i][j][k][p] = min(dp[i][j][k][p],dp[i - 1][j][k][0] + v[leftid + 1] - v[leftid]);
                            }
                        }else{
                            if(j == 0 || rightid == n)continue;
                            ///to rightside
                            ///from leftside
                            if(k != 0 && dist + dp[i - 1][j - 1][k - 1][0] <= v2[rightid]){
                                dp[i][j][k][p] = min(dp[i][j][k][p],dist + dp[i - 1][j - 1][k - 1][0]);
                            }else{
                                if(i != k)dp[i][j][k][p] = min(dp[i][j][k][p],dist + dp[i - 1][j - 1][k][0]);
                            }
                            ///from rightside
                            if(k != 0 && (v[rightid] - v[rightid - 1]) + dp[i - 1][j - 1][k - 1][1] <= v2[rightid]){
                                dp[i][j][k][p] = min(dp[i][j][k][p],(v[rightid] - v[rightid - 1]) + dp[i - 1][j - 1][k - 1][1]);
                            }else{
                                if(i != k)dp[i][j][k][p] = min(dp[i][j][k][p],(v[rightid] - v[rightid - 1]) + dp[i - 1][j - 1][k][1]);
                            }
                        }
                        if(dp[i][j][k][p] != inf){
                            ans = max(ans,k);
                        }
                        //cout<<dp[i][j][k][p]<<' '<<i<<' '<<j<<' '<<k<<' '<<p<<' '<<dist<<' '<<leftid<<' '<<v[leftid + 1]<<' '<<v[leftid]<<' '<<(v[rightid] - v[rightid - 1])<<'\n';
                    }
                }
            }
        }
    }
    cout<<ans<<'\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4540 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 0 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4540 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 0 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6588 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 6492 KB Output is correct
31 Correct 1 ms 6492 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 1 ms 6488 KB Output is correct
34 Correct 1 ms 6492 KB Output is correct
35 Correct 1 ms 6596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4540 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 0 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 41 ms 44464 KB Output is correct
19 Correct 16 ms 33944 KB Output is correct
20 Correct 8 ms 27740 KB Output is correct
21 Correct 15 ms 32996 KB Output is correct
22 Correct 21 ms 38748 KB Output is correct
23 Correct 6 ms 24900 KB Output is correct
24 Correct 5 ms 23388 KB Output is correct
25 Correct 6 ms 24924 KB Output is correct
26 Correct 3 ms 20824 KB Output is correct
27 Correct 8 ms 25232 KB Output is correct
28 Correct 7 ms 24412 KB Output is correct
29 Correct 6 ms 23900 KB Output is correct
30 Correct 5 ms 23748 KB Output is correct
31 Correct 6 ms 24924 KB Output is correct
32 Correct 3 ms 20060 KB Output is correct
33 Correct 6 ms 24920 KB Output is correct
34 Correct 3 ms 18780 KB Output is correct
35 Correct 6 ms 24752 KB Output is correct
36 Correct 3 ms 19548 KB Output is correct
37 Correct 6 ms 25028 KB Output is correct
38 Correct 4 ms 20200 KB Output is correct
39 Correct 7 ms 24156 KB Output is correct
40 Correct 4 ms 22108 KB Output is correct
41 Incorrect 43 ms 50616 KB Output isn't correct
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4540 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 0 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 6492 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 1 ms 6588 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 1 ms 6492 KB Output is correct
25 Correct 1 ms 6492 KB Output is correct
26 Correct 1 ms 6492 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 1 ms 6492 KB Output is correct
30 Correct 1 ms 6492 KB Output is correct
31 Correct 1 ms 6492 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 1 ms 6488 KB Output is correct
34 Correct 1 ms 6492 KB Output is correct
35 Correct 1 ms 6596 KB Output is correct
36 Correct 41 ms 44464 KB Output is correct
37 Correct 16 ms 33944 KB Output is correct
38 Correct 8 ms 27740 KB Output is correct
39 Correct 15 ms 32996 KB Output is correct
40 Correct 21 ms 38748 KB Output is correct
41 Correct 6 ms 24900 KB Output is correct
42 Correct 5 ms 23388 KB Output is correct
43 Correct 6 ms 24924 KB Output is correct
44 Correct 3 ms 20824 KB Output is correct
45 Correct 8 ms 25232 KB Output is correct
46 Correct 7 ms 24412 KB Output is correct
47 Correct 6 ms 23900 KB Output is correct
48 Correct 5 ms 23748 KB Output is correct
49 Correct 6 ms 24924 KB Output is correct
50 Correct 3 ms 20060 KB Output is correct
51 Correct 6 ms 24920 KB Output is correct
52 Correct 3 ms 18780 KB Output is correct
53 Correct 6 ms 24752 KB Output is correct
54 Correct 3 ms 19548 KB Output is correct
55 Correct 6 ms 25028 KB Output is correct
56 Correct 4 ms 20200 KB Output is correct
57 Correct 7 ms 24156 KB Output is correct
58 Correct 4 ms 22108 KB Output is correct
59 Incorrect 43 ms 50616 KB Output isn't correct
60 Halted 0 ms 0 KB -