Submission #233714

# Submission time Handle Problem Language Result Execution time Memory
233714 2020-05-21T13:48:59 Z duality Collecting Stamps 3 (JOI20_ho_t3) C++11
100 / 100
356 ms 127640 KB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int LLI;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

int N,L,X[200],T[200];
LLI dp[201][201][201][2];
LLI findAns(int a,int b,int s,int c) {
    if (s < 0) return 1e18;
    else if ((a == 0) && (b == 0)) return (s == 0) ? 0:1e18;
    else if ((c == 0) && (a == 0)) return 1e18;
    else if ((c == 1) && (b == 0)) return 1e18;
    else if (dp[a][b][s][c] != -1) return dp[a][b][s][c];
    LLI ans = 1e18;
    if (c == 0) {
        ans = min(ans,findAns(a-1,b,s,0)+X[a-1]-((a == 1) ? 0:X[a-2]));
        LLI x = findAns(a-1,b,s-1,0)+X[a-1]-((a == 1) ? 0:X[a-2]);
        if (x <= T[a-1]) ans = min(ans,x);
        if (b > 0) {
            ans = min(ans,findAns(a-1,b,s,1)+X[a-1]+L-X[N-b]);
            LLI x = findAns(a-1,b,s-1,1)+X[a-1]+L-X[N-b];
            if (x <= T[a-1]) ans = min(ans,x);
        }
    }
    else {
        ans = min(ans,findAns(a,b-1,s,1)+((b == 1) ? L:X[N-b+1])-X[N-b]);
        LLI x = findAns(a,b-1,s-1,1)+((b == 1) ? L:X[N-b+1])-X[N-b];
        if (x <= T[N-b]) ans = min(ans,x);
        if (a > 0) {
            ans = min(ans,findAns(a,b-1,s,0)+X[a-1]+L-X[N-b]);
            LLI x = findAns(a,b-1,s-1,0)+X[a-1]+L-X[N-b];
            if (x <= T[N-b]) ans = min(ans,x);
        }
    }
    dp[a][b][s][c] = ans;
    return ans;
}
int main() {
    int i,j;
    scanf("%d %d",&N,&L);
    for (i = 0; i < N; i++) scanf("%d",&X[i]);
    for (i = 0; i < N; i++) scanf("%d",&T[i]);
    memset(dp,-1,sizeof(dp));
    for (i = N; i >= 0; i--) {
        for (j = 0; j <= N; j++) {
            if (findAns(j,N-j,i,0) < 1e18) break;
            if (findAns(j,N-j,i,1) < 1e18) break;
        }
        if (j <= N) break;
    }
    printf("%d\n",i);

    return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:44: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:45:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i < N; i++) scanf("%d",&X[i]);
                             ~~~~~^~~~~~~~~~~~
ho_t3.cpp:46:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i = 0; i < N; i++) scanf("%d",&T[i]);
                             ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 67 ms 127352 KB Output is correct
2 Correct 67 ms 127480 KB Output is correct
3 Correct 73 ms 127352 KB Output is correct
4 Correct 69 ms 127432 KB Output is correct
5 Correct 71 ms 127480 KB Output is correct
6 Correct 70 ms 127480 KB Output is correct
7 Correct 68 ms 127480 KB Output is correct
8 Correct 68 ms 127480 KB Output is correct
9 Correct 67 ms 127480 KB Output is correct
10 Correct 68 ms 127492 KB Output is correct
11 Correct 67 ms 127480 KB Output is correct
12 Correct 67 ms 127480 KB Output is correct
13 Correct 69 ms 127480 KB Output is correct
14 Correct 67 ms 127480 KB Output is correct
15 Correct 67 ms 127480 KB Output is correct
16 Correct 67 ms 127352 KB Output is correct
17 Correct 68 ms 127480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 127352 KB Output is correct
2 Correct 67 ms 127480 KB Output is correct
3 Correct 73 ms 127352 KB Output is correct
4 Correct 69 ms 127432 KB Output is correct
5 Correct 71 ms 127480 KB Output is correct
6 Correct 70 ms 127480 KB Output is correct
7 Correct 68 ms 127480 KB Output is correct
8 Correct 68 ms 127480 KB Output is correct
9 Correct 67 ms 127480 KB Output is correct
10 Correct 68 ms 127492 KB Output is correct
11 Correct 67 ms 127480 KB Output is correct
12 Correct 67 ms 127480 KB Output is correct
13 Correct 69 ms 127480 KB Output is correct
14 Correct 67 ms 127480 KB Output is correct
15 Correct 67 ms 127480 KB Output is correct
16 Correct 67 ms 127352 KB Output is correct
17 Correct 68 ms 127480 KB Output is correct
18 Correct 68 ms 127480 KB Output is correct
19 Correct 69 ms 127480 KB Output is correct
20 Correct 70 ms 127480 KB Output is correct
21 Correct 71 ms 127352 KB Output is correct
22 Correct 67 ms 127480 KB Output is correct
23 Correct 69 ms 127480 KB Output is correct
24 Correct 67 ms 127480 KB Output is correct
25 Correct 67 ms 127480 KB Output is correct
26 Correct 70 ms 127480 KB Output is correct
27 Correct 68 ms 127480 KB Output is correct
28 Correct 68 ms 127480 KB Output is correct
29 Correct 68 ms 127480 KB Output is correct
30 Correct 70 ms 127480 KB Output is correct
31 Correct 70 ms 127480 KB Output is correct
32 Correct 69 ms 127480 KB Output is correct
33 Correct 70 ms 127480 KB Output is correct
34 Correct 68 ms 127480 KB Output is correct
35 Correct 68 ms 127480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 127352 KB Output is correct
2 Correct 67 ms 127480 KB Output is correct
3 Correct 73 ms 127352 KB Output is correct
4 Correct 69 ms 127432 KB Output is correct
5 Correct 71 ms 127480 KB Output is correct
6 Correct 70 ms 127480 KB Output is correct
7 Correct 68 ms 127480 KB Output is correct
8 Correct 68 ms 127480 KB Output is correct
9 Correct 67 ms 127480 KB Output is correct
10 Correct 68 ms 127492 KB Output is correct
11 Correct 67 ms 127480 KB Output is correct
12 Correct 67 ms 127480 KB Output is correct
13 Correct 69 ms 127480 KB Output is correct
14 Correct 67 ms 127480 KB Output is correct
15 Correct 67 ms 127480 KB Output is correct
16 Correct 67 ms 127352 KB Output is correct
17 Correct 68 ms 127480 KB Output is correct
18 Correct 237 ms 127480 KB Output is correct
19 Correct 135 ms 127480 KB Output is correct
20 Correct 96 ms 127500 KB Output is correct
21 Correct 139 ms 127484 KB Output is correct
22 Correct 155 ms 127480 KB Output is correct
23 Correct 77 ms 127484 KB Output is correct
24 Correct 83 ms 127480 KB Output is correct
25 Correct 77 ms 127480 KB Output is correct
26 Correct 74 ms 127480 KB Output is correct
27 Correct 78 ms 127480 KB Output is correct
28 Correct 80 ms 127480 KB Output is correct
29 Correct 88 ms 127480 KB Output is correct
30 Correct 86 ms 127480 KB Output is correct
31 Correct 87 ms 127480 KB Output is correct
32 Correct 76 ms 127480 KB Output is correct
33 Correct 87 ms 127608 KB Output is correct
34 Correct 73 ms 127484 KB Output is correct
35 Correct 95 ms 127500 KB Output is correct
36 Correct 73 ms 127480 KB Output is correct
37 Correct 100 ms 127496 KB Output is correct
38 Correct 77 ms 127480 KB Output is correct
39 Correct 105 ms 127460 KB Output is correct
40 Correct 78 ms 127480 KB Output is correct
41 Correct 242 ms 127480 KB Output is correct
42 Correct 240 ms 127480 KB Output is correct
43 Correct 236 ms 127640 KB Output is correct
44 Correct 250 ms 127608 KB Output is correct
45 Correct 221 ms 127480 KB Output is correct
46 Correct 220 ms 127480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 127352 KB Output is correct
2 Correct 67 ms 127480 KB Output is correct
3 Correct 73 ms 127352 KB Output is correct
4 Correct 69 ms 127432 KB Output is correct
5 Correct 71 ms 127480 KB Output is correct
6 Correct 70 ms 127480 KB Output is correct
7 Correct 68 ms 127480 KB Output is correct
8 Correct 68 ms 127480 KB Output is correct
9 Correct 67 ms 127480 KB Output is correct
10 Correct 68 ms 127492 KB Output is correct
11 Correct 67 ms 127480 KB Output is correct
12 Correct 67 ms 127480 KB Output is correct
13 Correct 69 ms 127480 KB Output is correct
14 Correct 67 ms 127480 KB Output is correct
15 Correct 67 ms 127480 KB Output is correct
16 Correct 67 ms 127352 KB Output is correct
17 Correct 68 ms 127480 KB Output is correct
18 Correct 68 ms 127480 KB Output is correct
19 Correct 69 ms 127480 KB Output is correct
20 Correct 70 ms 127480 KB Output is correct
21 Correct 71 ms 127352 KB Output is correct
22 Correct 67 ms 127480 KB Output is correct
23 Correct 69 ms 127480 KB Output is correct
24 Correct 67 ms 127480 KB Output is correct
25 Correct 67 ms 127480 KB Output is correct
26 Correct 70 ms 127480 KB Output is correct
27 Correct 68 ms 127480 KB Output is correct
28 Correct 68 ms 127480 KB Output is correct
29 Correct 68 ms 127480 KB Output is correct
30 Correct 70 ms 127480 KB Output is correct
31 Correct 70 ms 127480 KB Output is correct
32 Correct 69 ms 127480 KB Output is correct
33 Correct 70 ms 127480 KB Output is correct
34 Correct 68 ms 127480 KB Output is correct
35 Correct 68 ms 127480 KB Output is correct
36 Correct 237 ms 127480 KB Output is correct
37 Correct 135 ms 127480 KB Output is correct
38 Correct 96 ms 127500 KB Output is correct
39 Correct 139 ms 127484 KB Output is correct
40 Correct 155 ms 127480 KB Output is correct
41 Correct 77 ms 127484 KB Output is correct
42 Correct 83 ms 127480 KB Output is correct
43 Correct 77 ms 127480 KB Output is correct
44 Correct 74 ms 127480 KB Output is correct
45 Correct 78 ms 127480 KB Output is correct
46 Correct 80 ms 127480 KB Output is correct
47 Correct 88 ms 127480 KB Output is correct
48 Correct 86 ms 127480 KB Output is correct
49 Correct 87 ms 127480 KB Output is correct
50 Correct 76 ms 127480 KB Output is correct
51 Correct 87 ms 127608 KB Output is correct
52 Correct 73 ms 127484 KB Output is correct
53 Correct 95 ms 127500 KB Output is correct
54 Correct 73 ms 127480 KB Output is correct
55 Correct 100 ms 127496 KB Output is correct
56 Correct 77 ms 127480 KB Output is correct
57 Correct 105 ms 127460 KB Output is correct
58 Correct 78 ms 127480 KB Output is correct
59 Correct 242 ms 127480 KB Output is correct
60 Correct 240 ms 127480 KB Output is correct
61 Correct 236 ms 127640 KB Output is correct
62 Correct 250 ms 127608 KB Output is correct
63 Correct 221 ms 127480 KB Output is correct
64 Correct 220 ms 127480 KB Output is correct
65 Correct 261 ms 127608 KB Output is correct
66 Correct 233 ms 127488 KB Output is correct
67 Correct 236 ms 127608 KB Output is correct
68 Correct 211 ms 127480 KB Output is correct
69 Correct 265 ms 127512 KB Output is correct
70 Correct 135 ms 127480 KB Output is correct
71 Correct 254 ms 127480 KB Output is correct
72 Correct 137 ms 127480 KB Output is correct
73 Correct 242 ms 127480 KB Output is correct
74 Correct 129 ms 127480 KB Output is correct
75 Correct 251 ms 127484 KB Output is correct
76 Correct 218 ms 127480 KB Output is correct
77 Correct 306 ms 127536 KB Output is correct
78 Correct 189 ms 127480 KB Output is correct
79 Correct 239 ms 127484 KB Output is correct
80 Correct 177 ms 127480 KB Output is correct
81 Correct 223 ms 127608 KB Output is correct
82 Correct 261 ms 127480 KB Output is correct
83 Correct 324 ms 127480 KB Output is correct
84 Correct 280 ms 127608 KB Output is correct
85 Correct 263 ms 127568 KB Output is correct
86 Correct 298 ms 127608 KB Output is correct
87 Correct 242 ms 127632 KB Output is correct
88 Correct 161 ms 127480 KB Output is correct
89 Correct 218 ms 127516 KB Output is correct
90 Correct 316 ms 127508 KB Output is correct
91 Correct 158 ms 127480 KB Output is correct
92 Correct 245 ms 127480 KB Output is correct
93 Correct 356 ms 127480 KB Output is correct