답안 #638888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638888 2022-09-07T20:50:20 Z new_acc Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
85 ms 135256 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=2e2+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e16;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
ll t1[N],t2[N],n,dp[N][N][2][N],xd;
void solve(){
    cin>>n>>xd;
    for(int i=1;i<=n;i++) cin>>t1[i];
    for(int i=1;i<=n;i++) cin>>t2[i];
    for(int i=0;i<=n+1;i++){
        for(int i2=0;i2<=n+1;i2++){
            for(int i3=0;i3<2;i3++){
                for(int i4=1;i4<=n+1;i4++) dp[i][i2][i3][i4]=-1;
                dp[i][i2][i3][0]=INFl;
            }
        }
    }
    for(int i=n;i>=0;i--){
        for(int i2=n-i;i2>=0;i2--){
            for(int i3=0;i3<2;i3++){
                for(int i4=1;i4<=n-(i+i2)+1;i4++){
                    if(!i3 and i==0) continue;
                    if(i3 and i2==0) continue;
                    if(i+i2==n){
                        if(!i3) dp[i][i2][i3][i4]=t2[i]; 
                        else dp[i][i2][i3][i4]=t2[n-i2+1];
                        continue;
                    }
                    if(!i3){
                        dp[i][i2][i3][i4]=max({dp[i][i2][i3][i4],
                            min(dp[i+1][i2][i3][i4-1]-(t1[i+1]-t1[i]),t2[i]),
                            dp[i+1][i2][i3][i4]-(t1[i+1]-t1[i]),
                            min(dp[i][i2+1][1][i4-1]-(t1[i]+xd-t1[n-i2]),t2[i]),
                            dp[i][i2+1][1][i4]-(t1[i]+xd-t1[n-i2])});
                    }else{
                        dp[i][i2][i3][i4]=max({dp[i][i2][i3][i4],
                        min(dp[i][i2+1][i3][i4-1]-(t1[n-i2+1]-t1[n-i2]),t2[n-i2+1]),
                            dp[i][i2+1][i3][i4]-(t1[n-i2+1]-t1[n-i2]),
                        min(dp[i+1][i2][0][i4-1]-(xd-t1[n-i2+1]+t1[i+1]),t2[n-i2+1]),
                            dp[i+1][i2][0][i4]-(xd-t1[n-i2+1]+t1[i+1])});
                    }                    
                }
            }
        }
    }
    int res=0;
    for(int i=1;i<=n;i++){
        if(dp[1][0][0][i]-t1[1]>=0 or dp[0][1][1][i]-(xd-t1[n])>=0) res=i;
    }
    cout<<res<<"\n";
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int tt=1;
    while(tt--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 0 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 0 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 844 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 1228 KB Output is correct
30 Correct 1 ms 1236 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1228 KB Output is correct
35 Correct 1 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 0 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 56 ms 108708 KB Output is correct
19 Correct 33 ms 66132 KB Output is correct
20 Correct 17 ms 35600 KB Output is correct
21 Correct 31 ms 62528 KB Output is correct
22 Correct 41 ms 80836 KB Output is correct
23 Correct 15 ms 30288 KB Output is correct
24 Correct 12 ms 23752 KB Output is correct
25 Correct 15 ms 29652 KB Output is correct
26 Correct 5 ms 11604 KB Output is correct
27 Correct 20 ms 31004 KB Output is correct
28 Correct 12 ms 22100 KB Output is correct
29 Correct 16 ms 31560 KB Output is correct
30 Correct 12 ms 24932 KB Output is correct
31 Correct 15 ms 29636 KB Output is correct
32 Correct 7 ms 15700 KB Output is correct
33 Correct 14 ms 29644 KB Output is correct
34 Correct 5 ms 10836 KB Output is correct
35 Correct 15 ms 29000 KB Output is correct
36 Correct 8 ms 14036 KB Output is correct
37 Correct 15 ms 30968 KB Output is correct
38 Correct 9 ms 17100 KB Output is correct
39 Correct 16 ms 32208 KB Output is correct
40 Correct 10 ms 19020 KB Output is correct
41 Correct 85 ms 133936 KB Output is correct
42 Correct 52 ms 90456 KB Output is correct
43 Correct 76 ms 133932 KB Output is correct
44 Correct 46 ms 89376 KB Output is correct
45 Correct 79 ms 133880 KB Output is correct
46 Correct 44 ms 90468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 980 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 0 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 980 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 844 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 1228 KB Output is correct
30 Correct 1 ms 1236 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1228 KB Output is correct
35 Correct 1 ms 1236 KB Output is correct
36 Correct 56 ms 108708 KB Output is correct
37 Correct 33 ms 66132 KB Output is correct
38 Correct 17 ms 35600 KB Output is correct
39 Correct 31 ms 62528 KB Output is correct
40 Correct 41 ms 80836 KB Output is correct
41 Correct 15 ms 30288 KB Output is correct
42 Correct 12 ms 23752 KB Output is correct
43 Correct 15 ms 29652 KB Output is correct
44 Correct 5 ms 11604 KB Output is correct
45 Correct 20 ms 31004 KB Output is correct
46 Correct 12 ms 22100 KB Output is correct
47 Correct 16 ms 31560 KB Output is correct
48 Correct 12 ms 24932 KB Output is correct
49 Correct 15 ms 29636 KB Output is correct
50 Correct 7 ms 15700 KB Output is correct
51 Correct 14 ms 29644 KB Output is correct
52 Correct 5 ms 10836 KB Output is correct
53 Correct 15 ms 29000 KB Output is correct
54 Correct 8 ms 14036 KB Output is correct
55 Correct 15 ms 30968 KB Output is correct
56 Correct 9 ms 17100 KB Output is correct
57 Correct 16 ms 32208 KB Output is correct
58 Correct 10 ms 19020 KB Output is correct
59 Correct 85 ms 133936 KB Output is correct
60 Correct 52 ms 90456 KB Output is correct
61 Correct 76 ms 133932 KB Output is correct
62 Correct 46 ms 89376 KB Output is correct
63 Correct 79 ms 133880 KB Output is correct
64 Correct 44 ms 90468 KB Output is correct
65 Correct 70 ms 120956 KB Output is correct
66 Correct 65 ms 111112 KB Output is correct
67 Correct 55 ms 106316 KB Output is correct
68 Correct 51 ms 98252 KB Output is correct
69 Correct 62 ms 119716 KB Output is correct
70 Correct 64 ms 114792 KB Output is correct
71 Correct 78 ms 116028 KB Output is correct
72 Correct 61 ms 117188 KB Output is correct
73 Correct 58 ms 108740 KB Output is correct
74 Correct 53 ms 101680 KB Output is correct
75 Correct 59 ms 112332 KB Output is correct
76 Correct 67 ms 128624 KB Output is correct
77 Correct 68 ms 128568 KB Output is correct
78 Correct 54 ms 99396 KB Output is correct
79 Correct 56 ms 102856 KB Output is correct
80 Correct 67 ms 126196 KB Output is correct
81 Correct 57 ms 103908 KB Output is correct
82 Correct 62 ms 109864 KB Output is correct
83 Correct 76 ms 133940 KB Output is correct
84 Correct 60 ms 114788 KB Output is correct
85 Correct 66 ms 124788 KB Output is correct
86 Correct 65 ms 122244 KB Output is correct
87 Correct 59 ms 112360 KB Output is correct
88 Correct 85 ms 135256 KB Output is correct
89 Correct 81 ms 135256 KB Output is correct
90 Correct 62 ms 113560 KB Output is correct
91 Correct 72 ms 135232 KB Output is correct
92 Correct 73 ms 135244 KB Output is correct
93 Correct 71 ms 132616 KB Output is correct