답안 #959266

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

const long long MX = 220;

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

void update(long long l,long long r,long long k,long long side,long long time)
{
    long long 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);

	long long n, rd;
	cin>>n>>rd;

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

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

	for(long long i = 1; i <= n; i++)
    {
        for(long long j = 1; j <= i; j++)
        {
            for(long long k = 0; k <= i; k++)
			{
				long long l = j;
				long long 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 36 ms 166996 KB Output is correct
2 Correct 35 ms 167068 KB Output is correct
3 Correct 37 ms 167000 KB Output is correct
4 Correct 35 ms 166996 KB Output is correct
5 Correct 35 ms 167004 KB Output is correct
6 Correct 37 ms 166948 KB Output is correct
7 Correct 36 ms 166992 KB Output is correct
8 Correct 35 ms 166992 KB Output is correct
9 Correct 35 ms 166908 KB Output is correct
10 Correct 36 ms 166996 KB Output is correct
11 Correct 40 ms 166992 KB Output is correct
12 Correct 38 ms 167004 KB Output is correct
13 Correct 35 ms 166912 KB Output is correct
14 Correct 39 ms 166992 KB Output is correct
15 Correct 35 ms 167000 KB Output is correct
16 Correct 35 ms 167124 KB Output is correct
17 Correct 36 ms 167004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 166996 KB Output is correct
2 Correct 35 ms 167068 KB Output is correct
3 Correct 37 ms 167000 KB Output is correct
4 Correct 35 ms 166996 KB Output is correct
5 Correct 35 ms 167004 KB Output is correct
6 Correct 37 ms 166948 KB Output is correct
7 Correct 36 ms 166992 KB Output is correct
8 Correct 35 ms 166992 KB Output is correct
9 Correct 35 ms 166908 KB Output is correct
10 Correct 36 ms 166996 KB Output is correct
11 Correct 40 ms 166992 KB Output is correct
12 Correct 38 ms 167004 KB Output is correct
13 Correct 35 ms 166912 KB Output is correct
14 Correct 39 ms 166992 KB Output is correct
15 Correct 35 ms 167000 KB Output is correct
16 Correct 35 ms 167124 KB Output is correct
17 Correct 36 ms 167004 KB Output is correct
18 Correct 36 ms 167000 KB Output is correct
19 Correct 35 ms 166996 KB Output is correct
20 Correct 38 ms 166992 KB Output is correct
21 Correct 35 ms 167000 KB Output is correct
22 Correct 42 ms 166992 KB Output is correct
23 Correct 36 ms 167004 KB Output is correct
24 Correct 41 ms 166992 KB Output is correct
25 Correct 40 ms 166968 KB Output is correct
26 Correct 37 ms 166992 KB Output is correct
27 Correct 36 ms 166996 KB Output is correct
28 Correct 36 ms 167004 KB Output is correct
29 Correct 36 ms 167000 KB Output is correct
30 Correct 36 ms 166992 KB Output is correct
31 Correct 36 ms 167000 KB Output is correct
32 Correct 36 ms 167004 KB Output is correct
33 Correct 37 ms 167088 KB Output is correct
34 Correct 36 ms 166916 KB Output is correct
35 Correct 36 ms 167004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 166996 KB Output is correct
2 Correct 35 ms 167068 KB Output is correct
3 Correct 37 ms 167000 KB Output is correct
4 Correct 35 ms 166996 KB Output is correct
5 Correct 35 ms 167004 KB Output is correct
6 Correct 37 ms 166948 KB Output is correct
7 Correct 36 ms 166992 KB Output is correct
8 Correct 35 ms 166992 KB Output is correct
9 Correct 35 ms 166908 KB Output is correct
10 Correct 36 ms 166996 KB Output is correct
11 Correct 40 ms 166992 KB Output is correct
12 Correct 38 ms 167004 KB Output is correct
13 Correct 35 ms 166912 KB Output is correct
14 Correct 39 ms 166992 KB Output is correct
15 Correct 35 ms 167000 KB Output is correct
16 Correct 35 ms 167124 KB Output is correct
17 Correct 36 ms 167004 KB Output is correct
18 Correct 61 ms 166996 KB Output is correct
19 Correct 48 ms 166972 KB Output is correct
20 Correct 42 ms 166996 KB Output is correct
21 Correct 47 ms 166920 KB Output is correct
22 Correct 51 ms 166992 KB Output is correct
23 Correct 44 ms 167252 KB Output is correct
24 Correct 38 ms 167096 KB Output is correct
25 Correct 40 ms 167080 KB Output is correct
26 Correct 37 ms 166996 KB Output is correct
27 Correct 41 ms 167104 KB Output is correct
28 Correct 38 ms 166992 KB Output is correct
29 Correct 42 ms 167144 KB Output is correct
30 Correct 43 ms 167104 KB Output is correct
31 Correct 43 ms 167076 KB Output is correct
32 Correct 39 ms 167340 KB Output is correct
33 Correct 40 ms 166996 KB Output is correct
34 Correct 37 ms 167004 KB Output is correct
35 Correct 43 ms 167256 KB Output is correct
36 Correct 38 ms 167028 KB Output is correct
37 Correct 39 ms 166996 KB Output is correct
38 Correct 39 ms 167004 KB Output is correct
39 Correct 43 ms 166992 KB Output is correct
40 Correct 42 ms 167040 KB Output is correct
41 Correct 76 ms 167136 KB Output is correct
42 Correct 44 ms 166996 KB Output is correct
43 Correct 68 ms 166996 KB Output is correct
44 Correct 47 ms 166996 KB Output is correct
45 Correct 70 ms 167028 KB Output is correct
46 Correct 44 ms 166992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 166996 KB Output is correct
2 Correct 35 ms 167068 KB Output is correct
3 Correct 37 ms 167000 KB Output is correct
4 Correct 35 ms 166996 KB Output is correct
5 Correct 35 ms 167004 KB Output is correct
6 Correct 37 ms 166948 KB Output is correct
7 Correct 36 ms 166992 KB Output is correct
8 Correct 35 ms 166992 KB Output is correct
9 Correct 35 ms 166908 KB Output is correct
10 Correct 36 ms 166996 KB Output is correct
11 Correct 40 ms 166992 KB Output is correct
12 Correct 38 ms 167004 KB Output is correct
13 Correct 35 ms 166912 KB Output is correct
14 Correct 39 ms 166992 KB Output is correct
15 Correct 35 ms 167000 KB Output is correct
16 Correct 35 ms 167124 KB Output is correct
17 Correct 36 ms 167004 KB Output is correct
18 Correct 36 ms 167000 KB Output is correct
19 Correct 35 ms 166996 KB Output is correct
20 Correct 38 ms 166992 KB Output is correct
21 Correct 35 ms 167000 KB Output is correct
22 Correct 42 ms 166992 KB Output is correct
23 Correct 36 ms 167004 KB Output is correct
24 Correct 41 ms 166992 KB Output is correct
25 Correct 40 ms 166968 KB Output is correct
26 Correct 37 ms 166992 KB Output is correct
27 Correct 36 ms 166996 KB Output is correct
28 Correct 36 ms 167004 KB Output is correct
29 Correct 36 ms 167000 KB Output is correct
30 Correct 36 ms 166992 KB Output is correct
31 Correct 36 ms 167000 KB Output is correct
32 Correct 36 ms 167004 KB Output is correct
33 Correct 37 ms 167088 KB Output is correct
34 Correct 36 ms 166916 KB Output is correct
35 Correct 36 ms 167004 KB Output is correct
36 Correct 61 ms 166996 KB Output is correct
37 Correct 48 ms 166972 KB Output is correct
38 Correct 42 ms 166996 KB Output is correct
39 Correct 47 ms 166920 KB Output is correct
40 Correct 51 ms 166992 KB Output is correct
41 Correct 44 ms 167252 KB Output is correct
42 Correct 38 ms 167096 KB Output is correct
43 Correct 40 ms 167080 KB Output is correct
44 Correct 37 ms 166996 KB Output is correct
45 Correct 41 ms 167104 KB Output is correct
46 Correct 38 ms 166992 KB Output is correct
47 Correct 42 ms 167144 KB Output is correct
48 Correct 43 ms 167104 KB Output is correct
49 Correct 43 ms 167076 KB Output is correct
50 Correct 39 ms 167340 KB Output is correct
51 Correct 40 ms 166996 KB Output is correct
52 Correct 37 ms 167004 KB Output is correct
53 Correct 43 ms 167256 KB Output is correct
54 Correct 38 ms 167028 KB Output is correct
55 Correct 39 ms 166996 KB Output is correct
56 Correct 39 ms 167004 KB Output is correct
57 Correct 43 ms 166992 KB Output is correct
58 Correct 42 ms 167040 KB Output is correct
59 Correct 76 ms 167136 KB Output is correct
60 Correct 44 ms 166996 KB Output is correct
61 Correct 68 ms 166996 KB Output is correct
62 Correct 47 ms 166996 KB Output is correct
63 Correct 70 ms 167028 KB Output is correct
64 Correct 44 ms 166992 KB Output is correct
65 Correct 63 ms 166992 KB Output is correct
66 Correct 59 ms 166992 KB Output is correct
67 Correct 58 ms 166992 KB Output is correct
68 Correct 60 ms 166992 KB Output is correct
69 Correct 65 ms 167136 KB Output is correct
70 Correct 75 ms 167120 KB Output is correct
71 Correct 57 ms 166928 KB Output is correct
72 Correct 66 ms 167096 KB Output is correct
73 Correct 53 ms 167248 KB Output is correct
74 Correct 62 ms 166996 KB Output is correct
75 Correct 57 ms 166992 KB Output is correct
76 Correct 68 ms 166996 KB Output is correct
77 Correct 64 ms 167004 KB Output is correct
78 Correct 58 ms 167004 KB Output is correct
79 Correct 58 ms 167144 KB Output is correct
80 Correct 71 ms 167140 KB Output is correct
81 Correct 55 ms 167016 KB Output is correct
82 Correct 55 ms 167144 KB Output is correct
83 Correct 67 ms 167136 KB Output is correct
84 Correct 55 ms 166996 KB Output is correct
85 Correct 55 ms 166996 KB Output is correct
86 Correct 58 ms 167140 KB Output is correct
87 Correct 60 ms 166948 KB Output is correct
88 Correct 75 ms 166996 KB Output is correct
89 Correct 70 ms 166992 KB Output is correct
90 Correct 49 ms 166992 KB Output is correct
91 Correct 80 ms 167148 KB Output is correct
92 Correct 74 ms 166996 KB Output is correct
93 Correct 51 ms 167072 KB Output is correct