답안 #724706

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724706 2023-04-15T18:02:59 Z vjudge1 Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
106 ms 133620 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5+10;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int main(){
  	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    // freopen("shuffle.in","r",stdin);
    // freopen("shuffle.out","w",stdout);

	int n; ll l; cin >> n >> l;

	vector<ll> arr, tempo;
	for(int i=0;i<n;i++){
		ll x; cin >> x;
		arr.pb(x);
	}
	arr.pb(l);
	for(int i=0;i<n;i++) arr.pb(arr[i]+l);

	tempo.resize(2*n+1);
	for(int i=0;i<n;i++) cin >> tempo[i];
	for(int i=0;i<n;i++) tempo[i+n+1]=tempo[i];
	tempo[n]=-1;

	ll dp[205][205][405];
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=2*n;k++) 
				dp[i][j][k]=INF;
	dp[0][0][n]=0;

	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			for(int pos=0;pos<=2*n;pos++){
				if(dp[i][j][pos]==INF) continue;
				int nxd, nxu;

				if(pos>n){
					nxu=pos+1;
					nxd=nxu-i-2;
				}
				else{
					nxd=pos-1;
					nxu=nxd+i+2;
				}

				// cout << i << " " << pos << " " << nxd << " " << nxu << "\n";

				// if(j==3) cout << i << " " << pos << " " << nxd << " " << nxu << "\n";

				ll curr=dp[i][j][pos]+abs(arr[pos]-arr[nxd]);
				if(nxd>=0 && tempo[nxd]>=curr){
					// if(j+1==5) cout << i << " " << pos << " " << nxd << " " << nxu << "\n";
					ans=max(ans, j+1);
					dp[i+1][j+1][nxd]=min(dp[i+1][j+1][nxd], curr);
				}
				else if(nxd>=0) dp[i+1][j][nxd]=min(dp[i+1][j][nxd], curr);

				curr=dp[i][j][pos]+abs(arr[pos]-arr[nxu]);
				if(nxu<=2*n && tempo[nxu]>=curr){
					// if(j+1==5) cout << i << " " << pos << " " << nxd << " " << nxu << "\n";
					ans=max(ans, j+1);
					dp[i+1][j+1][nxu]=min(dp[i+1][j+1][nxu], curr);
				}
				else if(nxu<=2*n) dp[i+1][j][nxu]=min(dp[i+1][j][nxu], curr);
			}
		}
	}

	cout << ans << "\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 133452 KB Output is correct
2 Correct 53 ms 133524 KB Output is correct
3 Correct 52 ms 133460 KB Output is correct
4 Correct 52 ms 133476 KB Output is correct
5 Correct 51 ms 133472 KB Output is correct
6 Correct 55 ms 133476 KB Output is correct
7 Correct 53 ms 133500 KB Output is correct
8 Correct 50 ms 133456 KB Output is correct
9 Correct 50 ms 133572 KB Output is correct
10 Correct 51 ms 133472 KB Output is correct
11 Correct 59 ms 133432 KB Output is correct
12 Correct 52 ms 133500 KB Output is correct
13 Correct 52 ms 133484 KB Output is correct
14 Correct 52 ms 133492 KB Output is correct
15 Correct 51 ms 133432 KB Output is correct
16 Correct 52 ms 133400 KB Output is correct
17 Correct 51 ms 133404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 133452 KB Output is correct
2 Correct 53 ms 133524 KB Output is correct
3 Correct 52 ms 133460 KB Output is correct
4 Correct 52 ms 133476 KB Output is correct
5 Correct 51 ms 133472 KB Output is correct
6 Correct 55 ms 133476 KB Output is correct
7 Correct 53 ms 133500 KB Output is correct
8 Correct 50 ms 133456 KB Output is correct
9 Correct 50 ms 133572 KB Output is correct
10 Correct 51 ms 133472 KB Output is correct
11 Correct 59 ms 133432 KB Output is correct
12 Correct 52 ms 133500 KB Output is correct
13 Correct 52 ms 133484 KB Output is correct
14 Correct 52 ms 133492 KB Output is correct
15 Correct 51 ms 133432 KB Output is correct
16 Correct 52 ms 133400 KB Output is correct
17 Correct 51 ms 133404 KB Output is correct
18 Correct 54 ms 133512 KB Output is correct
19 Correct 50 ms 133440 KB Output is correct
20 Correct 50 ms 133504 KB Output is correct
21 Correct 52 ms 133420 KB Output is correct
22 Correct 51 ms 133496 KB Output is correct
23 Correct 56 ms 133496 KB Output is correct
24 Correct 51 ms 133408 KB Output is correct
25 Correct 51 ms 133452 KB Output is correct
26 Correct 52 ms 133524 KB Output is correct
27 Correct 52 ms 133452 KB Output is correct
28 Correct 52 ms 133556 KB Output is correct
29 Correct 50 ms 133460 KB Output is correct
30 Correct 51 ms 133452 KB Output is correct
31 Correct 50 ms 133504 KB Output is correct
32 Correct 50 ms 133452 KB Output is correct
33 Correct 50 ms 133452 KB Output is correct
34 Correct 51 ms 133408 KB Output is correct
35 Correct 49 ms 133460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 133452 KB Output is correct
2 Correct 53 ms 133524 KB Output is correct
3 Correct 52 ms 133460 KB Output is correct
4 Correct 52 ms 133476 KB Output is correct
5 Correct 51 ms 133472 KB Output is correct
6 Correct 55 ms 133476 KB Output is correct
7 Correct 53 ms 133500 KB Output is correct
8 Correct 50 ms 133456 KB Output is correct
9 Correct 50 ms 133572 KB Output is correct
10 Correct 51 ms 133472 KB Output is correct
11 Correct 59 ms 133432 KB Output is correct
12 Correct 52 ms 133500 KB Output is correct
13 Correct 52 ms 133484 KB Output is correct
14 Correct 52 ms 133492 KB Output is correct
15 Correct 51 ms 133432 KB Output is correct
16 Correct 52 ms 133400 KB Output is correct
17 Correct 51 ms 133404 KB Output is correct
18 Correct 82 ms 133532 KB Output is correct
19 Correct 66 ms 133496 KB Output is correct
20 Correct 56 ms 133476 KB Output is correct
21 Correct 66 ms 133452 KB Output is correct
22 Correct 71 ms 133416 KB Output is correct
23 Correct 54 ms 133496 KB Output is correct
24 Correct 54 ms 133436 KB Output is correct
25 Correct 56 ms 133516 KB Output is correct
26 Correct 51 ms 133460 KB Output is correct
27 Correct 62 ms 133524 KB Output is correct
28 Correct 54 ms 133488 KB Output is correct
29 Correct 59 ms 133524 KB Output is correct
30 Correct 54 ms 133416 KB Output is correct
31 Correct 58 ms 133456 KB Output is correct
32 Correct 52 ms 133480 KB Output is correct
33 Correct 56 ms 133456 KB Output is correct
34 Correct 50 ms 133452 KB Output is correct
35 Correct 54 ms 133420 KB Output is correct
36 Correct 51 ms 133508 KB Output is correct
37 Correct 54 ms 133488 KB Output is correct
38 Correct 51 ms 133452 KB Output is correct
39 Correct 55 ms 133528 KB Output is correct
40 Correct 54 ms 133508 KB Output is correct
41 Correct 100 ms 133520 KB Output is correct
42 Correct 72 ms 133612 KB Output is correct
43 Correct 93 ms 133492 KB Output is correct
44 Correct 66 ms 133432 KB Output is correct
45 Correct 94 ms 133540 KB Output is correct
46 Correct 66 ms 133456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 133452 KB Output is correct
2 Correct 53 ms 133524 KB Output is correct
3 Correct 52 ms 133460 KB Output is correct
4 Correct 52 ms 133476 KB Output is correct
5 Correct 51 ms 133472 KB Output is correct
6 Correct 55 ms 133476 KB Output is correct
7 Correct 53 ms 133500 KB Output is correct
8 Correct 50 ms 133456 KB Output is correct
9 Correct 50 ms 133572 KB Output is correct
10 Correct 51 ms 133472 KB Output is correct
11 Correct 59 ms 133432 KB Output is correct
12 Correct 52 ms 133500 KB Output is correct
13 Correct 52 ms 133484 KB Output is correct
14 Correct 52 ms 133492 KB Output is correct
15 Correct 51 ms 133432 KB Output is correct
16 Correct 52 ms 133400 KB Output is correct
17 Correct 51 ms 133404 KB Output is correct
18 Correct 54 ms 133512 KB Output is correct
19 Correct 50 ms 133440 KB Output is correct
20 Correct 50 ms 133504 KB Output is correct
21 Correct 52 ms 133420 KB Output is correct
22 Correct 51 ms 133496 KB Output is correct
23 Correct 56 ms 133496 KB Output is correct
24 Correct 51 ms 133408 KB Output is correct
25 Correct 51 ms 133452 KB Output is correct
26 Correct 52 ms 133524 KB Output is correct
27 Correct 52 ms 133452 KB Output is correct
28 Correct 52 ms 133556 KB Output is correct
29 Correct 50 ms 133460 KB Output is correct
30 Correct 51 ms 133452 KB Output is correct
31 Correct 50 ms 133504 KB Output is correct
32 Correct 50 ms 133452 KB Output is correct
33 Correct 50 ms 133452 KB Output is correct
34 Correct 51 ms 133408 KB Output is correct
35 Correct 49 ms 133460 KB Output is correct
36 Correct 82 ms 133532 KB Output is correct
37 Correct 66 ms 133496 KB Output is correct
38 Correct 56 ms 133476 KB Output is correct
39 Correct 66 ms 133452 KB Output is correct
40 Correct 71 ms 133416 KB Output is correct
41 Correct 54 ms 133496 KB Output is correct
42 Correct 54 ms 133436 KB Output is correct
43 Correct 56 ms 133516 KB Output is correct
44 Correct 51 ms 133460 KB Output is correct
45 Correct 62 ms 133524 KB Output is correct
46 Correct 54 ms 133488 KB Output is correct
47 Correct 59 ms 133524 KB Output is correct
48 Correct 54 ms 133416 KB Output is correct
49 Correct 58 ms 133456 KB Output is correct
50 Correct 52 ms 133480 KB Output is correct
51 Correct 56 ms 133456 KB Output is correct
52 Correct 50 ms 133452 KB Output is correct
53 Correct 54 ms 133420 KB Output is correct
54 Correct 51 ms 133508 KB Output is correct
55 Correct 54 ms 133488 KB Output is correct
56 Correct 51 ms 133452 KB Output is correct
57 Correct 55 ms 133528 KB Output is correct
58 Correct 54 ms 133508 KB Output is correct
59 Correct 100 ms 133520 KB Output is correct
60 Correct 72 ms 133612 KB Output is correct
61 Correct 93 ms 133492 KB Output is correct
62 Correct 66 ms 133432 KB Output is correct
63 Correct 94 ms 133540 KB Output is correct
64 Correct 66 ms 133456 KB Output is correct
65 Correct 90 ms 133444 KB Output is correct
66 Correct 90 ms 133540 KB Output is correct
67 Correct 82 ms 133444 KB Output is correct
68 Correct 75 ms 133484 KB Output is correct
69 Correct 89 ms 133580 KB Output is correct
70 Correct 86 ms 133544 KB Output is correct
71 Correct 93 ms 133504 KB Output is correct
72 Correct 88 ms 133452 KB Output is correct
73 Correct 78 ms 133536 KB Output is correct
74 Correct 83 ms 133424 KB Output is correct
75 Correct 80 ms 133620 KB Output is correct
76 Correct 98 ms 133452 KB Output is correct
77 Correct 86 ms 133420 KB Output is correct
78 Correct 85 ms 133544 KB Output is correct
79 Correct 85 ms 133452 KB Output is correct
80 Correct 106 ms 133544 KB Output is correct
81 Correct 84 ms 133444 KB Output is correct
82 Correct 78 ms 133524 KB Output is correct
83 Correct 99 ms 133540 KB Output is correct
84 Correct 80 ms 133496 KB Output is correct
85 Correct 86 ms 133528 KB Output is correct
86 Correct 92 ms 133520 KB Output is correct
87 Correct 86 ms 133568 KB Output is correct
88 Correct 98 ms 133512 KB Output is correct
89 Correct 96 ms 133508 KB Output is correct
90 Correct 75 ms 133580 KB Output is correct
91 Correct 98 ms 133488 KB Output is correct
92 Correct 92 ms 133452 KB Output is correct
93 Correct 73 ms 133528 KB Output is correct