답안 #510041

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
510041 2022-01-14T14:54:20 Z CSQ31 Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
140 ms 65264 KB
#include <bits/stdc++.h>
using namespace std;
int dp[205][205][205][2],n,L;
int x[400],t[400];
int dist(int l,int r){
	if(r >= l)return x[r] - x[l];
	return L-x[l] + x[r];
}
int main()
{
	cin>>n>>L;
	for(int i=1;i<=n;i++)cin>>x[i];
	for(int i=1;i<=n;i++)cin>>t[i];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n+1;k++)dp[i][j][k][0] = dp[i][j][k][1] = 2e9;
	}
	t[0] = -1;
	dp[0][0][0][0] = 0;
	n++;
	int ans = 0;
	for(int i=0;i<n;i++){
		for(int l=0;l<n;l++){
			for(int k=0;k<=n;k++){
				int r = (l+i)%n;
				for(int c=0;c<2;c++){
					if(dp[l][r][k][c] == 2e9)continue;
					//cout<<l<<" "<<r<<" "<<k<<" "<<c<<" "<<dp[l][r][k][c]<<'\n';
					ans = max(ans,k);
					int s = c?r:l;
					int ln = (l-1+n)%n;
					int d = dist(ln,s);
					int v = dp[l][r][k][c] + d;
					dp[ln][r][k][0] = min(dp[ln][r][k][0],v);
					if(t[ln] >= v)dp[ln][r][k+1][0] = min(dp[ln][r][k+1][0],v);
					
					int rn = (r+1)%n;
					d = dist(s,rn);
					v = dp[l][r][k][c] + d;
					dp[l][rn][k][1] = min(dp[l][rn][k][1],v);
					if(t[rn] >= v)dp[l][rn][k+1][1] = min(dp[l][rn][k+1][1],v);
				}
			}
			
		}
	}
	
	cout<<ans<<'\n';
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 424 KB Output is correct
6 Correct 0 ms 588 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 1 ms 556 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 552 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 0 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 424 KB Output is correct
6 Correct 0 ms 588 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 1 ms 556 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 552 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 0 ms 588 KB Output is correct
18 Incorrect 1 ms 684 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 424 KB Output is correct
6 Correct 0 ms 588 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 1 ms 556 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 552 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 0 ms 588 KB Output is correct
18 Correct 80 ms 52920 KB Output is correct
19 Correct 46 ms 32260 KB Output is correct
20 Correct 20 ms 17356 KB Output is correct
21 Correct 40 ms 30440 KB Output is correct
22 Correct 58 ms 39364 KB Output is correct
23 Correct 20 ms 14796 KB Output is correct
24 Correct 9 ms 11648 KB Output is correct
25 Correct 19 ms 14508 KB Output is correct
26 Correct 5 ms 5708 KB Output is correct
27 Correct 23 ms 15100 KB Output is correct
28 Correct 11 ms 10828 KB Output is correct
29 Correct 16 ms 15420 KB Output is correct
30 Correct 9 ms 12084 KB Output is correct
31 Correct 16 ms 14508 KB Output is correct
32 Correct 6 ms 7628 KB Output is correct
33 Correct 16 ms 14412 KB Output is correct
34 Correct 4 ms 5324 KB Output is correct
35 Correct 11 ms 14124 KB Output is correct
36 Correct 5 ms 6860 KB Output is correct
37 Correct 12 ms 15132 KB Output is correct
38 Correct 7 ms 8364 KB Output is correct
39 Correct 16 ms 15648 KB Output is correct
40 Correct 7 ms 9292 KB Output is correct
41 Correct 132 ms 65172 KB Output is correct
42 Correct 33 ms 43980 KB Output is correct
43 Correct 140 ms 65260 KB Output is correct
44 Correct 33 ms 43468 KB Output is correct
45 Correct 133 ms 65264 KB Output is correct
46 Correct 33 ms 44068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 408 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 0 ms 424 KB Output is correct
6 Correct 0 ms 588 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 1 ms 556 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 552 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 0 ms 588 KB Output is correct
18 Incorrect 1 ms 684 KB Output isn't correct
19 Halted 0 ms 0 KB -