답안 #515995

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
515995 2022-01-20T09:22:30 Z David_M Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
142 ms 130864 KB
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e13, P=998244353;


int n, ANS;
ll L;
ll dp[205][205][205][2];

void solve(){
    cin>>n>>L;
    vector<ll> a(n), T(n);
    for (auto &x:a)cin>>x;
    for (auto &x:T)cin>>x;

    for (int i=0; i<=n; i++)
        for (int j=0; j<=n; j++)
            for (int k=0; k<=n; k++)
                dp[i][j][k][0]=dp[i][j][k][1]=INF;
    dp[n][0][0][0]=dp[n][0][0][1]=0;

    for (int l=n; l>0; l--){
        for (int r=0; r<l; r++){
//            cout<<r<<" "<<l<<" "<<r+(n-l)<<endl;
            for (int ans=0; ans<=n; ans++){
                for (int i=0; i<2; i++){
                    ll curl=(l==n?L:a[l]);
                    ll curr=(r==0?0:a[r-1]);
                    ll t=dp[l][r][ans][i];
                    ll len=curr+(L-curl);
                    if(t>=INF)continue;
                    {
                    ll tt=t+(curl-a[l-1])+((ll)(i^0)*len);
                    int Ans=ans+(tt<=T[l-1]);
                    ll &next=dp[l-1][r][Ans][0];
                    next=min(tt, next);
                    ANS=max(Ans, ANS);
                    }
                    {
                    ll tt=t+(a[r]-curr)+((ll)(i^1)*len);
                    int Ans=ans+(tt<=T[r+0]);
                    ll &next=dp[l][r+1][Ans][1];
                    next=min(tt, next);
                    ANS=max(Ans, ANS);
                    }
                }
            }
        }
    }
    cout<<ANS;
}


main(){ios_base::sync_with_stdio(false), cin.tie(0);

	int T=1;
	//cin>>T;
    while(T--){
        solve();
    }

}

Compilation message

ho_t3.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main(){ios_base::sync_with_stdio(false), cin.tie(0);
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 0 ms 588 KB Output is correct
8 Correct 0 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 0 ms 588 KB Output is correct
16 Correct 1 ms 844 KB Output is correct
17 Correct 1 ms 840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 0 ms 588 KB Output is correct
8 Correct 0 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 0 ms 588 KB Output is correct
16 Correct 1 ms 844 KB Output is correct
17 Correct 1 ms 840 KB Output is correct
18 Correct 1 ms 976 KB Output is correct
19 Correct 0 ms 720 KB Output is correct
20 Correct 0 ms 848 KB Output is correct
21 Correct 1 ms 976 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 1104 KB Output is correct
24 Correct 1 ms 976 KB Output is correct
25 Correct 1 ms 976 KB Output is correct
26 Correct 1 ms 976 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 1096 KB Output is correct
30 Correct 1 ms 1092 KB Output is correct
31 Correct 1 ms 972 KB Output is correct
32 Correct 1 ms 956 KB Output is correct
33 Correct 1 ms 1092 KB Output is correct
34 Correct 1 ms 1104 KB Output is correct
35 Correct 1 ms 1104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 0 ms 588 KB Output is correct
8 Correct 0 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 0 ms 588 KB Output is correct
16 Correct 1 ms 844 KB Output is correct
17 Correct 1 ms 840 KB Output is correct
18 Correct 82 ms 104956 KB Output is correct
19 Correct 44 ms 63672 KB Output is correct
20 Correct 21 ms 33996 KB Output is correct
21 Correct 42 ms 60092 KB Output is correct
22 Correct 57 ms 77872 KB Output is correct
23 Correct 19 ms 28912 KB Output is correct
24 Correct 13 ms 22580 KB Output is correct
25 Correct 18 ms 28288 KB Output is correct
26 Correct 5 ms 10832 KB Output is correct
27 Correct 20 ms 29428 KB Output is correct
28 Correct 12 ms 21056 KB Output is correct
29 Correct 20 ms 30072 KB Output is correct
30 Correct 13 ms 23692 KB Output is correct
31 Correct 17 ms 28352 KB Output is correct
32 Correct 8 ms 14800 KB Output is correct
33 Correct 17 ms 28224 KB Output is correct
34 Correct 5 ms 10064 KB Output is correct
35 Correct 15 ms 27716 KB Output is correct
36 Correct 7 ms 13136 KB Output is correct
37 Correct 14 ms 29520 KB Output is correct
38 Correct 9 ms 16228 KB Output is correct
39 Correct 17 ms 30800 KB Output is correct
40 Correct 9 ms 18096 KB Output is correct
41 Correct 111 ms 129408 KB Output is correct
42 Correct 42 ms 87132 KB Output is correct
43 Correct 112 ms 129472 KB Output is correct
44 Correct 45 ms 86096 KB Output is correct
45 Correct 121 ms 129460 KB Output is correct
46 Correct 41 ms 87088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 0 ms 588 KB Output is correct
8 Correct 0 ms 716 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 844 KB Output is correct
13 Correct 1 ms 844 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 0 ms 588 KB Output is correct
16 Correct 1 ms 844 KB Output is correct
17 Correct 1 ms 840 KB Output is correct
18 Correct 1 ms 976 KB Output is correct
19 Correct 0 ms 720 KB Output is correct
20 Correct 0 ms 848 KB Output is correct
21 Correct 1 ms 976 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 1104 KB Output is correct
24 Correct 1 ms 976 KB Output is correct
25 Correct 1 ms 976 KB Output is correct
26 Correct 1 ms 976 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 592 KB Output is correct
29 Correct 1 ms 1096 KB Output is correct
30 Correct 1 ms 1092 KB Output is correct
31 Correct 1 ms 972 KB Output is correct
32 Correct 1 ms 956 KB Output is correct
33 Correct 1 ms 1092 KB Output is correct
34 Correct 1 ms 1104 KB Output is correct
35 Correct 1 ms 1104 KB Output is correct
36 Correct 82 ms 104956 KB Output is correct
37 Correct 44 ms 63672 KB Output is correct
38 Correct 21 ms 33996 KB Output is correct
39 Correct 42 ms 60092 KB Output is correct
40 Correct 57 ms 77872 KB Output is correct
41 Correct 19 ms 28912 KB Output is correct
42 Correct 13 ms 22580 KB Output is correct
43 Correct 18 ms 28288 KB Output is correct
44 Correct 5 ms 10832 KB Output is correct
45 Correct 20 ms 29428 KB Output is correct
46 Correct 12 ms 21056 KB Output is correct
47 Correct 20 ms 30072 KB Output is correct
48 Correct 13 ms 23692 KB Output is correct
49 Correct 17 ms 28352 KB Output is correct
50 Correct 8 ms 14800 KB Output is correct
51 Correct 17 ms 28224 KB Output is correct
52 Correct 5 ms 10064 KB Output is correct
53 Correct 15 ms 27716 KB Output is correct
54 Correct 7 ms 13136 KB Output is correct
55 Correct 14 ms 29520 KB Output is correct
56 Correct 9 ms 16228 KB Output is correct
57 Correct 17 ms 30800 KB Output is correct
58 Correct 9 ms 18096 KB Output is correct
59 Correct 111 ms 129408 KB Output is correct
60 Correct 42 ms 87132 KB Output is correct
61 Correct 112 ms 129472 KB Output is correct
62 Correct 45 ms 86096 KB Output is correct
63 Correct 121 ms 129460 KB Output is correct
64 Correct 41 ms 87088 KB Output is correct
65 Correct 99 ms 116936 KB Output is correct
66 Correct 85 ms 107196 KB Output is correct
67 Correct 87 ms 102660 KB Output is correct
68 Correct 69 ms 94660 KB Output is correct
69 Correct 93 ms 115668 KB Output is correct
70 Correct 96 ms 110780 KB Output is correct
71 Correct 86 ms 112052 KB Output is correct
72 Correct 99 ms 113212 KB Output is correct
73 Correct 69 ms 105004 KB Output is correct
74 Correct 82 ms 98112 KB Output is correct
75 Correct 82 ms 108452 KB Output is correct
76 Correct 119 ms 124364 KB Output is correct
77 Correct 98 ms 124340 KB Output is correct
78 Correct 77 ms 95816 KB Output is correct
79 Correct 79 ms 99236 KB Output is correct
80 Correct 109 ms 121900 KB Output is correct
81 Correct 76 ms 100372 KB Output is correct
82 Correct 72 ms 106040 KB Output is correct
83 Correct 105 ms 129468 KB Output is correct
84 Correct 73 ms 110792 KB Output is correct
85 Correct 89 ms 120596 KB Output is correct
86 Correct 100 ms 118124 KB Output is correct
87 Correct 96 ms 108468 KB Output is correct
88 Correct 130 ms 130736 KB Output is correct
89 Correct 116 ms 130864 KB Output is correct
90 Correct 53 ms 109536 KB Output is correct
91 Correct 142 ms 130760 KB Output is correct
92 Correct 110 ms 130724 KB Output is correct
93 Correct 64 ms 128072 KB Output is correct