Submission #201273

# Submission time Handle Problem Language Result Execution time Memory
201273 2020-02-10T05:49:54 Z arnold518 Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
75 ms 67960 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 200;
const ll INF = 1e16;

int N, ans;
ll L, X[MAXN+10], T[MAXN+10];
ll dp[MAXN+10][MAXN+10][MAXN+10][2];

int main()
{
	int i, j, k;

	scanf("%d%lld", &N, &L);
	for(i=1; i<=N; i++) scanf("%lld", &X[i]); X[N+1]=L;
	for(i=1; i<=N; i++) scanf("%lld", &T[i]);

	for(i=0; i<=N; i++)
	{
		for(j=N+1; j>i; j--)
		{
			for(k=0; k<=N; k++)
			{
				if(i==0 && j==N+1 && k==0) continue;
				dp[i][j][k][0]=dp[i][j][k][1]=INF;

				if(i-1>=0)
				{
					dp[i][j][k][0]=min(dp[i][j][k][0], dp[i-1][j][k][0]+X[i]-X[i-1]);
					dp[i][j][k][0]=min(dp[i][j][k][0], dp[i-1][j][k][1]+L-X[j]+X[i]);
					if(k && dp[i-1][j][k-1][0]+X[i]-X[i-1]<=T[i]) dp[i][j][k][0]=min(dp[i][j][k][0], dp[i-1][j][k-1][0]+X[i]-X[i-1]);
					if(k && dp[i-1][j][k-1][1]+L-X[j]+X[i]<=T[i]) dp[i][j][k][0]=min(dp[i][j][k][0], dp[i-1][j][k-1][1]+L-X[j]+X[i]);
				}

				if(j+1<=N+1)
				{
					dp[i][j][k][1]=min(dp[i][j][k][1], dp[i][j+1][k][1]+X[j+1]-X[j]);
					dp[i][j][k][1]=min(dp[i][j][k][1], dp[i][j+1][k][0]+L-X[j]+X[i]);
					if(k && dp[i][j+1][k-1][1]+X[j+1]-X[j]<=T[j]) dp[i][j][k][1]=min(dp[i][j][k][1], dp[i][j+1][k-1][1]+X[j+1]-X[j]);
					if(k && dp[i][j+1][k-1][0]+L-X[j]+X[i]<=T[j]) dp[i][j][k][1]=min(dp[i][j][k][1], dp[i][j+1][k-1][0]+L-X[j]+X[i]);
				}

				if(dp[i][j][k][0]!=INF) ans=max(ans, k);
				if(dp[i][j][k][1]!=INF) ans=max(ans, k);
			}
		}
	}
	printf("%d", ans);
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:20:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(i=1; i<=N; i++) scanf("%lld", &X[i]); X[N+1]=L;
  ^~~
ho_t3.cpp:20:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(i=1; i<=N; i++) scanf("%lld", &X[i]); X[N+1]=L;
                                            ^
ho_t3.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld", &N, &L);
  ~~~~~^~~~~~~~~~~~~~~~~~
ho_t3.cpp:20:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) scanf("%lld", &X[i]); X[N+1]=L;
                      ~~~~~^~~~~~~~~~~~~~~
ho_t3.cpp:21:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) scanf("%lld", &T[i]);
                      ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 632 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 632 KB Output is correct
17 Correct 5 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 632 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 632 KB Output is correct
17 Correct 5 ms 632 KB Output is correct
18 Correct 5 ms 764 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 5 ms 632 KB Output is correct
21 Correct 5 ms 760 KB Output is correct
22 Correct 5 ms 504 KB Output is correct
23 Correct 5 ms 888 KB Output is correct
24 Correct 5 ms 632 KB Output is correct
25 Correct 5 ms 760 KB Output is correct
26 Correct 5 ms 1016 KB Output is correct
27 Correct 5 ms 504 KB Output is correct
28 Correct 5 ms 504 KB Output is correct
29 Correct 5 ms 760 KB Output is correct
30 Correct 6 ms 888 KB Output is correct
31 Correct 5 ms 760 KB Output is correct
32 Correct 5 ms 632 KB Output is correct
33 Correct 5 ms 760 KB Output is correct
34 Correct 5 ms 760 KB Output is correct
35 Correct 5 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 632 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 632 KB Output is correct
17 Correct 5 ms 632 KB Output is correct
18 Correct 58 ms 54648 KB Output is correct
19 Correct 31 ms 33272 KB Output is correct
20 Correct 18 ms 17912 KB Output is correct
21 Correct 32 ms 31480 KB Output is correct
22 Correct 39 ms 40696 KB Output is correct
23 Correct 16 ms 15352 KB Output is correct
24 Correct 13 ms 12024 KB Output is correct
25 Correct 16 ms 14968 KB Output is correct
26 Correct 8 ms 5880 KB Output is correct
27 Correct 18 ms 15608 KB Output is correct
28 Correct 12 ms 11256 KB Output is correct
29 Correct 17 ms 15992 KB Output is correct
30 Correct 13 ms 12536 KB Output is correct
31 Correct 15 ms 14968 KB Output is correct
32 Correct 10 ms 8056 KB Output is correct
33 Correct 14 ms 14968 KB Output is correct
34 Correct 8 ms 5496 KB Output is correct
35 Correct 14 ms 14716 KB Output is correct
36 Correct 9 ms 7160 KB Output is correct
37 Correct 15 ms 15608 KB Output is correct
38 Correct 10 ms 8696 KB Output is correct
39 Correct 17 ms 16248 KB Output is correct
40 Correct 11 ms 9720 KB Output is correct
41 Correct 71 ms 67340 KB Output is correct
42 Correct 43 ms 45432 KB Output is correct
43 Correct 72 ms 67320 KB Output is correct
44 Correct 43 ms 44920 KB Output is correct
45 Correct 71 ms 67320 KB Output is correct
46 Correct 43 ms 45432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 632 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 5 ms 632 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 632 KB Output is correct
17 Correct 5 ms 632 KB Output is correct
18 Correct 5 ms 764 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 5 ms 632 KB Output is correct
21 Correct 5 ms 760 KB Output is correct
22 Correct 5 ms 504 KB Output is correct
23 Correct 5 ms 888 KB Output is correct
24 Correct 5 ms 632 KB Output is correct
25 Correct 5 ms 760 KB Output is correct
26 Correct 5 ms 1016 KB Output is correct
27 Correct 5 ms 504 KB Output is correct
28 Correct 5 ms 504 KB Output is correct
29 Correct 5 ms 760 KB Output is correct
30 Correct 6 ms 888 KB Output is correct
31 Correct 5 ms 760 KB Output is correct
32 Correct 5 ms 632 KB Output is correct
33 Correct 5 ms 760 KB Output is correct
34 Correct 5 ms 760 KB Output is correct
35 Correct 5 ms 760 KB Output is correct
36 Correct 58 ms 54648 KB Output is correct
37 Correct 31 ms 33272 KB Output is correct
38 Correct 18 ms 17912 KB Output is correct
39 Correct 32 ms 31480 KB Output is correct
40 Correct 39 ms 40696 KB Output is correct
41 Correct 16 ms 15352 KB Output is correct
42 Correct 13 ms 12024 KB Output is correct
43 Correct 16 ms 14968 KB Output is correct
44 Correct 8 ms 5880 KB Output is correct
45 Correct 18 ms 15608 KB Output is correct
46 Correct 12 ms 11256 KB Output is correct
47 Correct 17 ms 15992 KB Output is correct
48 Correct 13 ms 12536 KB Output is correct
49 Correct 15 ms 14968 KB Output is correct
50 Correct 10 ms 8056 KB Output is correct
51 Correct 14 ms 14968 KB Output is correct
52 Correct 8 ms 5496 KB Output is correct
53 Correct 14 ms 14716 KB Output is correct
54 Correct 9 ms 7160 KB Output is correct
55 Correct 15 ms 15608 KB Output is correct
56 Correct 10 ms 8696 KB Output is correct
57 Correct 17 ms 16248 KB Output is correct
58 Correct 11 ms 9720 KB Output is correct
59 Correct 71 ms 67340 KB Output is correct
60 Correct 43 ms 45432 KB Output is correct
61 Correct 72 ms 67320 KB Output is correct
62 Correct 43 ms 44920 KB Output is correct
63 Correct 71 ms 67320 KB Output is correct
64 Correct 43 ms 45432 KB Output is correct
65 Correct 61 ms 60736 KB Output is correct
66 Correct 58 ms 55804 KB Output is correct
67 Correct 63 ms 53636 KB Output is correct
68 Correct 50 ms 49528 KB Output is correct
69 Correct 60 ms 60152 KB Output is correct
70 Correct 61 ms 57720 KB Output is correct
71 Correct 63 ms 58232 KB Output is correct
72 Correct 63 ms 58872 KB Output is correct
73 Correct 53 ms 54648 KB Output is correct
74 Correct 62 ms 51064 KB Output is correct
75 Correct 61 ms 56440 KB Output is correct
76 Correct 71 ms 64628 KB Output is correct
77 Correct 69 ms 64632 KB Output is correct
78 Correct 51 ms 49912 KB Output is correct
79 Correct 52 ms 51704 KB Output is correct
80 Correct 67 ms 63352 KB Output is correct
81 Correct 54 ms 52216 KB Output is correct
82 Correct 55 ms 55288 KB Output is correct
83 Correct 68 ms 67320 KB Output is correct
84 Correct 59 ms 57720 KB Output is correct
85 Correct 65 ms 62712 KB Output is correct
86 Correct 64 ms 61432 KB Output is correct
87 Correct 57 ms 56440 KB Output is correct
88 Correct 73 ms 67960 KB Output is correct
89 Correct 75 ms 67960 KB Output is correct
90 Correct 56 ms 57084 KB Output is correct
91 Correct 74 ms 67960 KB Output is correct
92 Correct 74 ms 67960 KB Output is correct
93 Correct 66 ms 66680 KB Output is correct