답안 #959265

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
959265 2024-04-07T18:44:42 Z maxFedorchuk Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
47 ms 84056 KB
#include<bits/stdc++.h>
using namespace std;

const int MX = 220;

int t[MX], x[MX], ans;
int dp[MX][MX][MX][2];

void update(int l,int r,int k,int side,int time)
{
    int zar=((side==0)?l:r);
    k+=(t[zar]>=time);
    ans=max(ans,k);
    
    dp[l][r][k][side]=(((dp[l][r][k][side]==-1)|(dp[l][r][k][side]>time))?time:dp[l][r][k][side]);
}

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

	int n, rd;
	cin>>n>>rd;

	for(int i = 1; i <= n; i++)
		cin>>x[i];
    
	for(int i = 1; i <= n; i++)
		cin>>t[i];
    
	memset(dp, -1, sizeof(dp));

	x[0] = 0;

	update(1, n, 0, 0, x[1]);
	update(1, n, 0, 1, rd - x[n]);

	for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= i; j++)
        {
            for(int k = 0; k <= i; k++)
			{
				int l = j;
				int r = n - i + j;

				if(l >= r)
                {
                    continue;
                }
                
				if(dp[l][r][k][0] != -1)
				{
					update(l+1, r, k, 0, dp[l][r][k][0] + x[l+1] - x[l]);
					update(l+1, r, k, 1, dp[l][r][k][0] + x[l] + rd - x[r]);
				}
				if(dp[l][r][k][1] != -1)
				{
					update(l, r-1, k, 1, dp[l][r][k][1] + (x[r] - x[r-1]));
					update(l, r-1, k, 0, dp[l][r][k][1] + (rd - x[r] + x[l]));
				}
			}
        }
    }
		
	cout<<ans<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 83536 KB Output is correct
2 Correct 12 ms 83620 KB Output is correct
3 Correct 12 ms 83640 KB Output is correct
4 Correct 12 ms 83804 KB Output is correct
5 Correct 12 ms 83804 KB Output is correct
6 Correct 12 ms 83800 KB Output is correct
7 Correct 13 ms 83804 KB Output is correct
8 Correct 13 ms 83804 KB Output is correct
9 Correct 12 ms 83812 KB Output is correct
10 Correct 12 ms 83804 KB Output is correct
11 Correct 12 ms 83804 KB Output is correct
12 Correct 11 ms 83804 KB Output is correct
13 Correct 11 ms 83804 KB Output is correct
14 Correct 12 ms 83548 KB Output is correct
15 Correct 13 ms 83616 KB Output is correct
16 Correct 12 ms 83804 KB Output is correct
17 Correct 11 ms 83612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 83536 KB Output is correct
2 Correct 12 ms 83620 KB Output is correct
3 Correct 12 ms 83640 KB Output is correct
4 Correct 12 ms 83804 KB Output is correct
5 Correct 12 ms 83804 KB Output is correct
6 Correct 12 ms 83800 KB Output is correct
7 Correct 13 ms 83804 KB Output is correct
8 Correct 13 ms 83804 KB Output is correct
9 Correct 12 ms 83812 KB Output is correct
10 Correct 12 ms 83804 KB Output is correct
11 Correct 12 ms 83804 KB Output is correct
12 Correct 11 ms 83804 KB Output is correct
13 Correct 11 ms 83804 KB Output is correct
14 Correct 12 ms 83548 KB Output is correct
15 Correct 13 ms 83616 KB Output is correct
16 Correct 12 ms 83804 KB Output is correct
17 Correct 11 ms 83612 KB Output is correct
18 Incorrect 12 ms 83804 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 83536 KB Output is correct
2 Correct 12 ms 83620 KB Output is correct
3 Correct 12 ms 83640 KB Output is correct
4 Correct 12 ms 83804 KB Output is correct
5 Correct 12 ms 83804 KB Output is correct
6 Correct 12 ms 83800 KB Output is correct
7 Correct 13 ms 83804 KB Output is correct
8 Correct 13 ms 83804 KB Output is correct
9 Correct 12 ms 83812 KB Output is correct
10 Correct 12 ms 83804 KB Output is correct
11 Correct 12 ms 83804 KB Output is correct
12 Correct 11 ms 83804 KB Output is correct
13 Correct 11 ms 83804 KB Output is correct
14 Correct 12 ms 83548 KB Output is correct
15 Correct 13 ms 83616 KB Output is correct
16 Correct 12 ms 83804 KB Output is correct
17 Correct 11 ms 83612 KB Output is correct
18 Correct 32 ms 83548 KB Output is correct
19 Correct 25 ms 83548 KB Output is correct
20 Correct 16 ms 83800 KB Output is correct
21 Correct 22 ms 83724 KB Output is correct
22 Correct 27 ms 83804 KB Output is correct
23 Correct 16 ms 84052 KB Output is correct
24 Correct 13 ms 83804 KB Output is correct
25 Correct 16 ms 83800 KB Output is correct
26 Correct 12 ms 83804 KB Output is correct
27 Correct 16 ms 83804 KB Output is correct
28 Correct 14 ms 83620 KB Output is correct
29 Correct 15 ms 83804 KB Output is correct
30 Correct 13 ms 83692 KB Output is correct
31 Correct 15 ms 83804 KB Output is correct
32 Correct 13 ms 84056 KB Output is correct
33 Correct 15 ms 83804 KB Output is correct
34 Correct 12 ms 83712 KB Output is correct
35 Correct 14 ms 83804 KB Output is correct
36 Correct 13 ms 83804 KB Output is correct
37 Correct 14 ms 83804 KB Output is correct
38 Correct 13 ms 83736 KB Output is correct
39 Correct 14 ms 83644 KB Output is correct
40 Correct 12 ms 83800 KB Output is correct
41 Correct 45 ms 83548 KB Output is correct
42 Correct 18 ms 83800 KB Output is correct
43 Correct 47 ms 83668 KB Output is correct
44 Correct 19 ms 83804 KB Output is correct
45 Correct 44 ms 83780 KB Output is correct
46 Correct 19 ms 83800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 83536 KB Output is correct
2 Correct 12 ms 83620 KB Output is correct
3 Correct 12 ms 83640 KB Output is correct
4 Correct 12 ms 83804 KB Output is correct
5 Correct 12 ms 83804 KB Output is correct
6 Correct 12 ms 83800 KB Output is correct
7 Correct 13 ms 83804 KB Output is correct
8 Correct 13 ms 83804 KB Output is correct
9 Correct 12 ms 83812 KB Output is correct
10 Correct 12 ms 83804 KB Output is correct
11 Correct 12 ms 83804 KB Output is correct
12 Correct 11 ms 83804 KB Output is correct
13 Correct 11 ms 83804 KB Output is correct
14 Correct 12 ms 83548 KB Output is correct
15 Correct 13 ms 83616 KB Output is correct
16 Correct 12 ms 83804 KB Output is correct
17 Correct 11 ms 83612 KB Output is correct
18 Incorrect 12 ms 83804 KB Output isn't correct
19 Halted 0 ms 0 KB -