# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20352 | 2017-02-07T07:37:12 Z | Can polan into space? (OJUZ11_space) | C++ | 111 ms | 9520 KB |
#include<bits/stdc++.h> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pii; int n; lint a[1000005], b[1000005], c[1000005], dp[1005][1005]; int trk[1005][1005]; lint f(int s, int e){ if(s > e) return 0; if(s == e){ if(n == 1) return a[s]; if(s == 1 || s == n) return b[s]; return c[s]; } if(~dp[s][e]) return dp[s][e]; lint ret = -1e18; for(int i=s; i<=e; i++){ int border = 0; if(i == s && s > 1) border++; if(i == e && e < n) border++; lint tmp = f(s, i-1) + f(i+1, e); if(border == 0) tmp += a[i]; if(border == 1) tmp += b[i]; if(border == 2) tmp += c[i]; if(ret < tmp){ ret = tmp; trk[s][e] = i; } } return dp[s][e] = ret; } void track(int s, int e){ if(s > e) return; if(s == e){ printf("%d ", s); return; } printf("%d ", trk[s][e]); track(s, trk[s][e] - 1); track(trk[s][e]+1, e); } int main(){ scanf("%d",&n); for(int i=1; i<=n; i++){ scanf("%lld %lld %lld",&a[i],&b[i],&c[i]); } if(n > 1000){ puts("-1"); return 0; } memset(dp, -1, sizeof(dp)); printf("%lld\n", f(1, n)); track(1, n); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8156 KB | Output is correct |
2 | Correct | 7 ms | 8336 KB | Output is correct |
3 | Correct | 6 ms | 8360 KB | Output is correct |
4 | Correct | 6 ms | 8360 KB | Output is correct |
5 | Correct | 6 ms | 8360 KB | Output is correct |
6 | Correct | 7 ms | 8360 KB | Output is correct |
7 | Correct | 6 ms | 8360 KB | Output is correct |
8 | Correct | 7 ms | 8360 KB | Output is correct |
9 | Correct | 6 ms | 8360 KB | Output is correct |
10 | Correct | 6 ms | 8360 KB | Output is correct |
11 | Correct | 6 ms | 8360 KB | Output is correct |
12 | Correct | 8 ms | 8360 KB | Output is correct |
13 | Correct | 6 ms | 8360 KB | Output is correct |
14 | Correct | 6 ms | 8360 KB | Output is correct |
15 | Correct | 7 ms | 8360 KB | Output is correct |
16 | Correct | 7 ms | 8360 KB | Output is correct |
17 | Correct | 6 ms | 8360 KB | Output is correct |
18 | Correct | 7 ms | 8360 KB | Output is correct |
19 | Correct | 6 ms | 8360 KB | Output is correct |
20 | Correct | 6 ms | 8360 KB | Output is correct |
21 | Correct | 6 ms | 8360 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8156 KB | Output is correct |
2 | Correct | 7 ms | 8336 KB | Output is correct |
3 | Correct | 6 ms | 8360 KB | Output is correct |
4 | Correct | 6 ms | 8360 KB | Output is correct |
5 | Correct | 6 ms | 8360 KB | Output is correct |
6 | Correct | 7 ms | 8360 KB | Output is correct |
7 | Correct | 6 ms | 8360 KB | Output is correct |
8 | Correct | 7 ms | 8360 KB | Output is correct |
9 | Correct | 6 ms | 8360 KB | Output is correct |
10 | Correct | 6 ms | 8360 KB | Output is correct |
11 | Correct | 6 ms | 8360 KB | Output is correct |
12 | Correct | 8 ms | 8360 KB | Output is correct |
13 | Correct | 6 ms | 8360 KB | Output is correct |
14 | Correct | 6 ms | 8360 KB | Output is correct |
15 | Correct | 7 ms | 8360 KB | Output is correct |
16 | Correct | 7 ms | 8360 KB | Output is correct |
17 | Correct | 6 ms | 8360 KB | Output is correct |
18 | Correct | 7 ms | 8360 KB | Output is correct |
19 | Correct | 6 ms | 8360 KB | Output is correct |
20 | Correct | 6 ms | 8360 KB | Output is correct |
21 | Correct | 6 ms | 8360 KB | Output is correct |
22 | Correct | 7 ms | 8360 KB | Output is correct |
23 | Correct | 7 ms | 8360 KB | Output is correct |
24 | Correct | 6 ms | 8360 KB | Output is correct |
25 | Correct | 6 ms | 8360 KB | Output is correct |
26 | Correct | 6 ms | 8360 KB | Output is correct |
27 | Correct | 6 ms | 8364 KB | Output is correct |
28 | Correct | 6 ms | 8364 KB | Output is correct |
29 | Correct | 6 ms | 8364 KB | Output is correct |
30 | Correct | 6 ms | 8364 KB | Output is correct |
31 | Correct | 6 ms | 8364 KB | Output is correct |
32 | Correct | 6 ms | 8364 KB | Output is correct |
33 | Correct | 7 ms | 8364 KB | Output is correct |
34 | Correct | 6 ms | 8364 KB | Output is correct |
35 | Correct | 6 ms | 8364 KB | Output is correct |
36 | Correct | 6 ms | 8364 KB | Output is correct |
37 | Correct | 7 ms | 8364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8156 KB | Output is correct |
2 | Correct | 7 ms | 8336 KB | Output is correct |
3 | Correct | 6 ms | 8360 KB | Output is correct |
4 | Correct | 6 ms | 8360 KB | Output is correct |
5 | Correct | 6 ms | 8360 KB | Output is correct |
6 | Correct | 7 ms | 8360 KB | Output is correct |
7 | Correct | 6 ms | 8360 KB | Output is correct |
8 | Correct | 7 ms | 8360 KB | Output is correct |
9 | Correct | 6 ms | 8360 KB | Output is correct |
10 | Correct | 6 ms | 8360 KB | Output is correct |
11 | Correct | 6 ms | 8360 KB | Output is correct |
12 | Correct | 8 ms | 8360 KB | Output is correct |
13 | Correct | 6 ms | 8360 KB | Output is correct |
14 | Correct | 6 ms | 8360 KB | Output is correct |
15 | Correct | 7 ms | 8360 KB | Output is correct |
16 | Correct | 7 ms | 8360 KB | Output is correct |
17 | Correct | 6 ms | 8360 KB | Output is correct |
18 | Correct | 7 ms | 8360 KB | Output is correct |
19 | Correct | 6 ms | 8360 KB | Output is correct |
20 | Correct | 6 ms | 8360 KB | Output is correct |
21 | Correct | 6 ms | 8360 KB | Output is correct |
22 | Correct | 7 ms | 8360 KB | Output is correct |
23 | Correct | 7 ms | 8360 KB | Output is correct |
24 | Correct | 6 ms | 8360 KB | Output is correct |
25 | Correct | 6 ms | 8360 KB | Output is correct |
26 | Correct | 6 ms | 8360 KB | Output is correct |
27 | Correct | 6 ms | 8364 KB | Output is correct |
28 | Correct | 6 ms | 8364 KB | Output is correct |
29 | Correct | 6 ms | 8364 KB | Output is correct |
30 | Correct | 6 ms | 8364 KB | Output is correct |
31 | Correct | 6 ms | 8364 KB | Output is correct |
32 | Correct | 6 ms | 8364 KB | Output is correct |
33 | Correct | 7 ms | 8364 KB | Output is correct |
34 | Correct | 6 ms | 8364 KB | Output is correct |
35 | Correct | 6 ms | 8364 KB | Output is correct |
36 | Correct | 6 ms | 8364 KB | Output is correct |
37 | Correct | 7 ms | 8364 KB | Output is correct |
38 | Correct | 7 ms | 8368 KB | Output is correct |
39 | Correct | 64 ms | 9516 KB | Output is correct |
40 | Correct | 61 ms | 9520 KB | Output is correct |
41 | Correct | 58 ms | 9520 KB | Output is correct |
42 | Correct | 60 ms | 9520 KB | Output is correct |
43 | Correct | 62 ms | 9520 KB | Output is correct |
44 | Correct | 57 ms | 9520 KB | Output is correct |
45 | Correct | 58 ms | 9520 KB | Output is correct |
46 | Correct | 42 ms | 9520 KB | Output is correct |
47 | Correct | 59 ms | 9520 KB | Output is correct |
48 | Correct | 13 ms | 9520 KB | Output is correct |
49 | Correct | 61 ms | 9520 KB | Output is correct |
50 | Correct | 57 ms | 9520 KB | Output is correct |
51 | Correct | 23 ms | 9520 KB | Output is correct |
52 | Correct | 85 ms | 9520 KB | Output is correct |
53 | Correct | 58 ms | 9520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8156 KB | Output is correct |
2 | Correct | 7 ms | 8336 KB | Output is correct |
3 | Correct | 6 ms | 8360 KB | Output is correct |
4 | Correct | 6 ms | 8360 KB | Output is correct |
5 | Correct | 6 ms | 8360 KB | Output is correct |
6 | Correct | 7 ms | 8360 KB | Output is correct |
7 | Correct | 6 ms | 8360 KB | Output is correct |
8 | Correct | 7 ms | 8360 KB | Output is correct |
9 | Correct | 6 ms | 8360 KB | Output is correct |
10 | Correct | 6 ms | 8360 KB | Output is correct |
11 | Correct | 6 ms | 8360 KB | Output is correct |
12 | Correct | 8 ms | 8360 KB | Output is correct |
13 | Correct | 6 ms | 8360 KB | Output is correct |
14 | Correct | 6 ms | 8360 KB | Output is correct |
15 | Correct | 7 ms | 8360 KB | Output is correct |
16 | Correct | 7 ms | 8360 KB | Output is correct |
17 | Correct | 6 ms | 8360 KB | Output is correct |
18 | Correct | 7 ms | 8360 KB | Output is correct |
19 | Correct | 6 ms | 8360 KB | Output is correct |
20 | Correct | 6 ms | 8360 KB | Output is correct |
21 | Correct | 6 ms | 8360 KB | Output is correct |
22 | Correct | 7 ms | 8360 KB | Output is correct |
23 | Correct | 7 ms | 8360 KB | Output is correct |
24 | Correct | 6 ms | 8360 KB | Output is correct |
25 | Correct | 6 ms | 8360 KB | Output is correct |
26 | Correct | 6 ms | 8360 KB | Output is correct |
27 | Correct | 6 ms | 8364 KB | Output is correct |
28 | Correct | 6 ms | 8364 KB | Output is correct |
29 | Correct | 6 ms | 8364 KB | Output is correct |
30 | Correct | 6 ms | 8364 KB | Output is correct |
31 | Correct | 6 ms | 8364 KB | Output is correct |
32 | Correct | 6 ms | 8364 KB | Output is correct |
33 | Correct | 7 ms | 8364 KB | Output is correct |
34 | Correct | 6 ms | 8364 KB | Output is correct |
35 | Correct | 6 ms | 8364 KB | Output is correct |
36 | Correct | 6 ms | 8364 KB | Output is correct |
37 | Correct | 7 ms | 8364 KB | Output is correct |
38 | Correct | 7 ms | 8368 KB | Output is correct |
39 | Correct | 64 ms | 9516 KB | Output is correct |
40 | Correct | 61 ms | 9520 KB | Output is correct |
41 | Correct | 58 ms | 9520 KB | Output is correct |
42 | Correct | 60 ms | 9520 KB | Output is correct |
43 | Correct | 62 ms | 9520 KB | Output is correct |
44 | Correct | 57 ms | 9520 KB | Output is correct |
45 | Correct | 58 ms | 9520 KB | Output is correct |
46 | Correct | 42 ms | 9520 KB | Output is correct |
47 | Correct | 59 ms | 9520 KB | Output is correct |
48 | Correct | 13 ms | 9520 KB | Output is correct |
49 | Correct | 61 ms | 9520 KB | Output is correct |
50 | Correct | 57 ms | 9520 KB | Output is correct |
51 | Correct | 23 ms | 9520 KB | Output is correct |
52 | Correct | 85 ms | 9520 KB | Output is correct |
53 | Correct | 58 ms | 9520 KB | Output is correct |
54 | Correct | 59 ms | 9520 KB | Output is correct |
55 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
56 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
57 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
58 | Incorrect | 7 ms | 9520 KB | Unexpected end of file - int32 expected |
59 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
60 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
61 | Incorrect | 5 ms | 9520 KB | Unexpected end of file - int32 expected |
62 | Incorrect | 5 ms | 9520 KB | Unexpected end of file - int32 expected |
63 | Incorrect | 2 ms | 9520 KB | Unexpected end of file - int32 expected |
64 | Incorrect | 7 ms | 9520 KB | Unexpected end of file - int32 expected |
65 | Incorrect | 5 ms | 9520 KB | Unexpected end of file - int32 expected |
66 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
67 | Incorrect | 4 ms | 9520 KB | Unexpected end of file - int32 expected |
68 | Incorrect | 3 ms | 9520 KB | Unexpected end of file - int32 expected |
69 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 8156 KB | Output is correct |
2 | Correct | 7 ms | 8336 KB | Output is correct |
3 | Correct | 6 ms | 8360 KB | Output is correct |
4 | Correct | 6 ms | 8360 KB | Output is correct |
5 | Correct | 6 ms | 8360 KB | Output is correct |
6 | Correct | 7 ms | 8360 KB | Output is correct |
7 | Correct | 6 ms | 8360 KB | Output is correct |
8 | Correct | 7 ms | 8360 KB | Output is correct |
9 | Correct | 6 ms | 8360 KB | Output is correct |
10 | Correct | 6 ms | 8360 KB | Output is correct |
11 | Correct | 6 ms | 8360 KB | Output is correct |
12 | Correct | 8 ms | 8360 KB | Output is correct |
13 | Correct | 6 ms | 8360 KB | Output is correct |
14 | Correct | 6 ms | 8360 KB | Output is correct |
15 | Correct | 7 ms | 8360 KB | Output is correct |
16 | Correct | 7 ms | 8360 KB | Output is correct |
17 | Correct | 6 ms | 8360 KB | Output is correct |
18 | Correct | 7 ms | 8360 KB | Output is correct |
19 | Correct | 6 ms | 8360 KB | Output is correct |
20 | Correct | 6 ms | 8360 KB | Output is correct |
21 | Correct | 6 ms | 8360 KB | Output is correct |
22 | Correct | 7 ms | 8360 KB | Output is correct |
23 | Correct | 7 ms | 8360 KB | Output is correct |
24 | Correct | 6 ms | 8360 KB | Output is correct |
25 | Correct | 6 ms | 8360 KB | Output is correct |
26 | Correct | 6 ms | 8360 KB | Output is correct |
27 | Correct | 6 ms | 8364 KB | Output is correct |
28 | Correct | 6 ms | 8364 KB | Output is correct |
29 | Correct | 6 ms | 8364 KB | Output is correct |
30 | Correct | 6 ms | 8364 KB | Output is correct |
31 | Correct | 6 ms | 8364 KB | Output is correct |
32 | Correct | 6 ms | 8364 KB | Output is correct |
33 | Correct | 7 ms | 8364 KB | Output is correct |
34 | Correct | 6 ms | 8364 KB | Output is correct |
35 | Correct | 6 ms | 8364 KB | Output is correct |
36 | Correct | 6 ms | 8364 KB | Output is correct |
37 | Correct | 7 ms | 8364 KB | Output is correct |
38 | Correct | 7 ms | 8368 KB | Output is correct |
39 | Correct | 64 ms | 9516 KB | Output is correct |
40 | Correct | 61 ms | 9520 KB | Output is correct |
41 | Correct | 58 ms | 9520 KB | Output is correct |
42 | Correct | 60 ms | 9520 KB | Output is correct |
43 | Correct | 62 ms | 9520 KB | Output is correct |
44 | Correct | 57 ms | 9520 KB | Output is correct |
45 | Correct | 58 ms | 9520 KB | Output is correct |
46 | Correct | 42 ms | 9520 KB | Output is correct |
47 | Correct | 59 ms | 9520 KB | Output is correct |
48 | Correct | 13 ms | 9520 KB | Output is correct |
49 | Correct | 61 ms | 9520 KB | Output is correct |
50 | Correct | 57 ms | 9520 KB | Output is correct |
51 | Correct | 23 ms | 9520 KB | Output is correct |
52 | Correct | 85 ms | 9520 KB | Output is correct |
53 | Correct | 58 ms | 9520 KB | Output is correct |
54 | Correct | 59 ms | 9520 KB | Output is correct |
55 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
56 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
57 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
58 | Incorrect | 7 ms | 9520 KB | Unexpected end of file - int32 expected |
59 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
60 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
61 | Incorrect | 5 ms | 9520 KB | Unexpected end of file - int32 expected |
62 | Incorrect | 5 ms | 9520 KB | Unexpected end of file - int32 expected |
63 | Incorrect | 2 ms | 9520 KB | Unexpected end of file - int32 expected |
64 | Incorrect | 7 ms | 9520 KB | Unexpected end of file - int32 expected |
65 | Incorrect | 5 ms | 9520 KB | Unexpected end of file - int32 expected |
66 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
67 | Incorrect | 4 ms | 9520 KB | Unexpected end of file - int32 expected |
68 | Incorrect | 3 ms | 9520 KB | Unexpected end of file - int32 expected |
69 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
70 | Incorrect | 6 ms | 9520 KB | Unexpected end of file - int32 expected |
71 | Incorrect | 101 ms | 9520 KB | Unexpected end of file - int32 expected |
72 | Incorrect | 83 ms | 9520 KB | Unexpected end of file - int32 expected |
73 | Incorrect | 105 ms | 9520 KB | Unexpected end of file - int32 expected |
74 | Incorrect | 66 ms | 9520 KB | Unexpected end of file - int32 expected |
75 | Incorrect | 100 ms | 9520 KB | Unexpected end of file - int32 expected |
76 | Incorrect | 100 ms | 9520 KB | Unexpected end of file - int32 expected |
77 | Incorrect | 42 ms | 9520 KB | Unexpected end of file - int32 expected |
78 | Incorrect | 100 ms | 9520 KB | Unexpected end of file - int32 expected |
79 | Incorrect | 109 ms | 9520 KB | Unexpected end of file - int32 expected |
80 | Incorrect | 105 ms | 9520 KB | Unexpected end of file - int32 expected |
81 | Incorrect | 25 ms | 9520 KB | Unexpected end of file - int32 expected |
82 | Incorrect | 72 ms | 9520 KB | Unexpected end of file - int32 expected |
83 | Incorrect | 101 ms | 9520 KB | Unexpected end of file - int32 expected |
84 | Incorrect | 111 ms | 9520 KB | Unexpected end of file - int32 expected |
85 | Incorrect | 101 ms | 9520 KB | Unexpected end of file - int32 expected |
86 | Incorrect | 101 ms | 9520 KB | Unexpected end of file - int32 expected |
87 | Incorrect | 100 ms | 9520 KB | Unexpected end of file - int32 expected |
88 | Incorrect | 17 ms | 9520 KB | Unexpected end of file - int32 expected |
89 | Incorrect | 58 ms | 9520 KB | Unexpected end of file - int32 expected |
90 | Incorrect | 35 ms | 9520 KB | Unexpected end of file - int32 expected |
91 | Incorrect | 5 ms | 9520 KB | Unexpected end of file - int32 expected |
92 | Incorrect | 36 ms | 9520 KB | Unexpected end of file - int32 expected |