Submission #227177

# Submission time Handle Problem Language Result Execution time Memory
227177 2020-04-26T10:40:02 Z ho94949 Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
104 ms 129528 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 200;
const long long INF = 0x3f3f3f3f'3f3f3f3fLL;

//leftmost: i, rightmost: j, visited: 0, cur: left or right. time
long long dp[MAXN+2][MAXN+2][MAXN+2][2]; 
int N, L;
int X[MAXN+1], T[MAXN+1];
int main()
{
    scanf("%d%d", &N, &L);
    for(int i=1; i<=N; ++i) scanf("%d", X+i);
    for(int i=1; i<=N; ++i) scanf("%d", T+i);
    memset(dp, 0x3f, sizeof dp);
    dp[N+1][0][0][0] = dp[N+1][0][0][1] = 0;

    int ans = 0;
    for(int imj = N; imj>0; --imj)
    {
        for(int i=imj; i<=N+1; ++i)
        {
            int j = i-imj;
            for(int t=0; t<=N-imj+1; ++t)
            {
                long long ptime, d;
                if(i != N+1)
                {
                    ptime = dp[i+1][j][t][0];
                    d = abs(X[i]-X[i+1]); d = min(d, L-d);
                    if(ptime+d<=T[i]) 
                        dp[i][j][t+1][0] = min(dp[i][j][t+1][0], ptime+d);
                    else 
                        dp[i][j][t][0] = min(dp[i][j][t][0], ptime+d);

                    ptime = dp[i+1][j][t][1];
                    d = abs(X[i]-X[j]); d = min(d, L-d);
                    if(ptime+d<=T[i]) 
                        dp[i][j][t+1][0] = min(dp[i][j][t+1][0], ptime+d);
                    else 
                        dp[i][j][t][0] = min(dp[i][j][t][0], ptime+d);
                }
                if(j != 0)
                {
                    ptime = dp[i][j-1][t][0];
                    d = abs(X[j]-X[i]); d = min(d, L-d);
                    if(ptime+d<=T[j]) 
                        dp[i][j][t+1][1] = min(dp[i][j][t+1][1], ptime+d);
                    else 
                        dp[i][j][t][1] = min(dp[i][j][t][1], ptime+d);

                    ptime = dp[i][j-1][t][1];
                    d = abs(X[j]-X[j-1]); d = min(d, L-d);
                    if(ptime+d<=T[j]) 
                        dp[i][j][t+1][1] = min(dp[i][j][t+1][1], ptime+d);
                    else 
                        dp[i][j][t][1] = min(dp[i][j][t][1], ptime+d);
                }
                if(dp[i][j][t][0] < INF || dp[i][j][t][1] <INF)
                    ans = max(ans, t);
                //printf("%d %d %d %lld %lld\n",i,j,t, dp[i][j][t][0], dp[i][j][t][1]);
            }
        }
    }
    for(int i=1; i<=N; ++i)
        for(int j=0; j<=N; ++j)
            if(dp[i][i][j][0]<INF || dp[i][i][j][1]<INF)
                ans = max(ans, j);
    printf("%d\n", ans);
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &L);
     ~~~~~^~~~~~~~~~~~~~~~
ho_t3.cpp:14:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=N; ++i) scanf("%d", X+i);
                             ~~~~~^~~~~~~~~~~
ho_t3.cpp:15:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=N; ++i) scanf("%d", T+i);
                             ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 66 ms 129400 KB Output is correct
2 Correct 66 ms 129400 KB Output is correct
3 Correct 66 ms 129400 KB Output is correct
4 Correct 65 ms 129404 KB Output is correct
5 Correct 67 ms 129400 KB Output is correct
6 Correct 64 ms 129400 KB Output is correct
7 Correct 65 ms 129400 KB Output is correct
8 Correct 67 ms 129400 KB Output is correct
9 Correct 67 ms 129400 KB Output is correct
10 Correct 65 ms 129400 KB Output is correct
11 Correct 67 ms 129400 KB Output is correct
12 Correct 65 ms 129400 KB Output is correct
13 Correct 66 ms 129400 KB Output is correct
14 Correct 65 ms 129400 KB Output is correct
15 Correct 65 ms 129400 KB Output is correct
16 Correct 66 ms 129400 KB Output is correct
17 Correct 64 ms 129400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 129400 KB Output is correct
2 Correct 66 ms 129400 KB Output is correct
3 Correct 66 ms 129400 KB Output is correct
4 Correct 65 ms 129404 KB Output is correct
5 Correct 67 ms 129400 KB Output is correct
6 Correct 64 ms 129400 KB Output is correct
7 Correct 65 ms 129400 KB Output is correct
8 Correct 67 ms 129400 KB Output is correct
9 Correct 67 ms 129400 KB Output is correct
10 Correct 65 ms 129400 KB Output is correct
11 Correct 67 ms 129400 KB Output is correct
12 Correct 65 ms 129400 KB Output is correct
13 Correct 66 ms 129400 KB Output is correct
14 Correct 65 ms 129400 KB Output is correct
15 Correct 65 ms 129400 KB Output is correct
16 Correct 66 ms 129400 KB Output is correct
17 Correct 64 ms 129400 KB Output is correct
18 Correct 66 ms 129404 KB Output is correct
19 Correct 65 ms 129400 KB Output is correct
20 Correct 64 ms 129404 KB Output is correct
21 Correct 65 ms 129400 KB Output is correct
22 Correct 64 ms 129400 KB Output is correct
23 Correct 64 ms 129400 KB Output is correct
24 Correct 64 ms 129400 KB Output is correct
25 Correct 64 ms 129400 KB Output is correct
26 Correct 66 ms 129400 KB Output is correct
27 Correct 65 ms 129400 KB Output is correct
28 Correct 65 ms 129400 KB Output is correct
29 Correct 65 ms 129400 KB Output is correct
30 Correct 65 ms 129404 KB Output is correct
31 Correct 65 ms 129400 KB Output is correct
32 Correct 66 ms 129400 KB Output is correct
33 Correct 64 ms 129400 KB Output is correct
34 Correct 66 ms 129400 KB Output is correct
35 Correct 66 ms 129400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 129400 KB Output is correct
2 Correct 66 ms 129400 KB Output is correct
3 Correct 66 ms 129400 KB Output is correct
4 Correct 65 ms 129404 KB Output is correct
5 Correct 67 ms 129400 KB Output is correct
6 Correct 64 ms 129400 KB Output is correct
7 Correct 65 ms 129400 KB Output is correct
8 Correct 67 ms 129400 KB Output is correct
9 Correct 67 ms 129400 KB Output is correct
10 Correct 65 ms 129400 KB Output is correct
11 Correct 67 ms 129400 KB Output is correct
12 Correct 65 ms 129400 KB Output is correct
13 Correct 66 ms 129400 KB Output is correct
14 Correct 65 ms 129400 KB Output is correct
15 Correct 65 ms 129400 KB Output is correct
16 Correct 66 ms 129400 KB Output is correct
17 Correct 64 ms 129400 KB Output is correct
18 Correct 91 ms 129400 KB Output is correct
19 Correct 87 ms 129400 KB Output is correct
20 Correct 71 ms 129400 KB Output is correct
21 Correct 79 ms 129400 KB Output is correct
22 Correct 82 ms 129400 KB Output is correct
23 Correct 69 ms 129400 KB Output is correct
24 Correct 67 ms 129400 KB Output is correct
25 Correct 68 ms 129400 KB Output is correct
26 Correct 66 ms 129400 KB Output is correct
27 Correct 72 ms 129528 KB Output is correct
28 Correct 67 ms 129400 KB Output is correct
29 Correct 70 ms 129400 KB Output is correct
30 Correct 68 ms 129400 KB Output is correct
31 Correct 68 ms 129400 KB Output is correct
32 Correct 66 ms 129400 KB Output is correct
33 Correct 68 ms 129432 KB Output is correct
34 Correct 66 ms 129400 KB Output is correct
35 Correct 78 ms 129400 KB Output is correct
36 Correct 66 ms 129400 KB Output is correct
37 Correct 68 ms 129404 KB Output is correct
38 Correct 66 ms 129400 KB Output is correct
39 Correct 69 ms 129400 KB Output is correct
40 Correct 67 ms 129400 KB Output is correct
41 Correct 99 ms 129400 KB Output is correct
42 Correct 84 ms 129400 KB Output is correct
43 Correct 97 ms 129400 KB Output is correct
44 Correct 82 ms 129400 KB Output is correct
45 Correct 99 ms 129400 KB Output is correct
46 Correct 82 ms 129400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 129400 KB Output is correct
2 Correct 66 ms 129400 KB Output is correct
3 Correct 66 ms 129400 KB Output is correct
4 Correct 65 ms 129404 KB Output is correct
5 Correct 67 ms 129400 KB Output is correct
6 Correct 64 ms 129400 KB Output is correct
7 Correct 65 ms 129400 KB Output is correct
8 Correct 67 ms 129400 KB Output is correct
9 Correct 67 ms 129400 KB Output is correct
10 Correct 65 ms 129400 KB Output is correct
11 Correct 67 ms 129400 KB Output is correct
12 Correct 65 ms 129400 KB Output is correct
13 Correct 66 ms 129400 KB Output is correct
14 Correct 65 ms 129400 KB Output is correct
15 Correct 65 ms 129400 KB Output is correct
16 Correct 66 ms 129400 KB Output is correct
17 Correct 64 ms 129400 KB Output is correct
18 Correct 66 ms 129404 KB Output is correct
19 Correct 65 ms 129400 KB Output is correct
20 Correct 64 ms 129404 KB Output is correct
21 Correct 65 ms 129400 KB Output is correct
22 Correct 64 ms 129400 KB Output is correct
23 Correct 64 ms 129400 KB Output is correct
24 Correct 64 ms 129400 KB Output is correct
25 Correct 64 ms 129400 KB Output is correct
26 Correct 66 ms 129400 KB Output is correct
27 Correct 65 ms 129400 KB Output is correct
28 Correct 65 ms 129400 KB Output is correct
29 Correct 65 ms 129400 KB Output is correct
30 Correct 65 ms 129404 KB Output is correct
31 Correct 65 ms 129400 KB Output is correct
32 Correct 66 ms 129400 KB Output is correct
33 Correct 64 ms 129400 KB Output is correct
34 Correct 66 ms 129400 KB Output is correct
35 Correct 66 ms 129400 KB Output is correct
36 Correct 91 ms 129400 KB Output is correct
37 Correct 87 ms 129400 KB Output is correct
38 Correct 71 ms 129400 KB Output is correct
39 Correct 79 ms 129400 KB Output is correct
40 Correct 82 ms 129400 KB Output is correct
41 Correct 69 ms 129400 KB Output is correct
42 Correct 67 ms 129400 KB Output is correct
43 Correct 68 ms 129400 KB Output is correct
44 Correct 66 ms 129400 KB Output is correct
45 Correct 72 ms 129528 KB Output is correct
46 Correct 67 ms 129400 KB Output is correct
47 Correct 70 ms 129400 KB Output is correct
48 Correct 68 ms 129400 KB Output is correct
49 Correct 68 ms 129400 KB Output is correct
50 Correct 66 ms 129400 KB Output is correct
51 Correct 68 ms 129432 KB Output is correct
52 Correct 66 ms 129400 KB Output is correct
53 Correct 78 ms 129400 KB Output is correct
54 Correct 66 ms 129400 KB Output is correct
55 Correct 68 ms 129404 KB Output is correct
56 Correct 66 ms 129400 KB Output is correct
57 Correct 69 ms 129400 KB Output is correct
58 Correct 67 ms 129400 KB Output is correct
59 Correct 99 ms 129400 KB Output is correct
60 Correct 84 ms 129400 KB Output is correct
61 Correct 97 ms 129400 KB Output is correct
62 Correct 82 ms 129400 KB Output is correct
63 Correct 99 ms 129400 KB Output is correct
64 Correct 82 ms 129400 KB Output is correct
65 Correct 91 ms 129400 KB Output is correct
66 Correct 90 ms 129400 KB Output is correct
67 Correct 89 ms 129400 KB Output is correct
68 Correct 89 ms 129400 KB Output is correct
69 Correct 91 ms 129400 KB Output is correct
70 Correct 90 ms 129400 KB Output is correct
71 Correct 91 ms 129400 KB Output is correct
72 Correct 90 ms 129400 KB Output is correct
73 Correct 90 ms 129400 KB Output is correct
74 Correct 85 ms 129400 KB Output is correct
75 Correct 87 ms 129400 KB Output is correct
76 Correct 97 ms 129400 KB Output is correct
77 Correct 96 ms 129400 KB Output is correct
78 Correct 85 ms 129528 KB Output is correct
79 Correct 85 ms 129400 KB Output is correct
80 Correct 93 ms 129400 KB Output is correct
81 Correct 86 ms 129528 KB Output is correct
82 Correct 89 ms 129400 KB Output is correct
83 Correct 97 ms 129400 KB Output is correct
84 Correct 88 ms 129400 KB Output is correct
85 Correct 96 ms 129400 KB Output is correct
86 Correct 94 ms 129400 KB Output is correct
87 Correct 87 ms 129400 KB Output is correct
88 Correct 97 ms 129400 KB Output is correct
89 Correct 95 ms 129404 KB Output is correct
90 Correct 89 ms 129400 KB Output is correct
91 Correct 104 ms 129400 KB Output is correct
92 Correct 98 ms 129400 KB Output is correct
93 Correct 100 ms 129400 KB Output is correct