# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20540 | 2017-02-12T08:52:15 Z | CYI(#67, choyi0521) | Can polan into space? (OJUZ11_space) | C++14 | 139 ms | 12052 KB |
#include<cstdio> #include<algorithm> using namespace std; int n, r[200001], p[200001],cnt, fr[200001][4]; long long dp[200001][4],res; void f(int x, int y) { if (!x) return; r[x] = y; f(x - 1, fr[x][y]); } int main() { int a, b, c; scanf("%d%d%d%d", &n,&a,&b,&c); if (n == 1) { printf("%d\n1", a); return 0; } dp[1][0] = a; dp[1][2] = b; dp[1][1] = dp[1][3] = -1e15; for (int i = 2; i <= n; i++) { scanf("%d%d%d", &a, &b, &c); if (dp[i - 1][2] > dp[i - 1][3]) { dp[i][0] = dp[i - 1][2] + a; fr[i][0] = 2; dp[i][2] = dp[i - 1][2] + b; fr[i][2] = 2; } else { dp[i][0] = dp[i - 1][3] + a; fr[i][0] = 3; dp[i][2] = dp[i - 1][3] + b; fr[i][2] = 3; } if (dp[i - 1][0] > dp[i - 1][1]) { dp[i][1] = dp[i - 1][0] + b; fr[i][1] = 0; dp[i][3] = dp[i - 1][0] + c; fr[i][3] = 0; } else { dp[i][1] = dp[i - 1][1] + b; fr[i][1] = 1; dp[i][3] = dp[i - 1][1] + c; fr[i][3] = 1; } } if (dp[n][0] > dp[n][1]) f(n, 0),res=dp[n][0]; else f(n, 1), res = dp[n][1]; for (int i = 1; i <= n; i++) if (!r[i]) p[i] = ++cnt; for (int i = 1; i <= n; i++) if (r[i] == 1) p[i] = ++cnt; for (int i = n; i >= 1; i--) if (r[i] == 2) p[i] = ++cnt; for (int i = 1; i <= n; i++) if (r[i] == 3) p[i] = ++cnt; printf("%lld\n", res); for (int i = 1; i <= n; i++) printf("%d ", p[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 12052 KB | Output is correct |
2 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
3 | Correct | 0 ms | 12052 KB | Output is correct |
4 | Correct | 0 ms | 12052 KB | Output is correct |
5 | Correct | 0 ms | 12052 KB | Output is correct |
6 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
7 | Correct | 0 ms | 12052 KB | Output is correct |
8 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
9 | Correct | 0 ms | 12052 KB | Output is correct |
10 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
11 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
12 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
13 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
14 | Correct | 0 ms | 12052 KB | Output is correct |
15 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
16 | Correct | 0 ms | 12052 KB | Output is correct |
17 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
18 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
19 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
20 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
21 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 12052 KB | Output is correct |
2 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
3 | Correct | 0 ms | 12052 KB | Output is correct |
4 | Correct | 0 ms | 12052 KB | Output is correct |
5 | Correct | 0 ms | 12052 KB | Output is correct |
6 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
7 | Correct | 0 ms | 12052 KB | Output is correct |
8 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
9 | Correct | 0 ms | 12052 KB | Output is correct |
10 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
11 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
12 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
13 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
14 | Correct | 0 ms | 12052 KB | Output is correct |
15 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
16 | Correct | 0 ms | 12052 KB | Output is correct |
17 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
18 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
19 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
20 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
21 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
22 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
23 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
24 | Correct | 0 ms | 12052 KB | Output is correct |
25 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
26 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
27 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
28 | Correct | 0 ms | 12052 KB | Output is correct |
29 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
30 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
31 | Correct | 0 ms | 12052 KB | Output is correct |
32 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
33 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
34 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
35 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
36 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
37 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 12052 KB | Output is correct |
2 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
3 | Correct | 0 ms | 12052 KB | Output is correct |
4 | Correct | 0 ms | 12052 KB | Output is correct |
5 | Correct | 0 ms | 12052 KB | Output is correct |
6 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
7 | Correct | 0 ms | 12052 KB | Output is correct |
8 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
9 | Correct | 0 ms | 12052 KB | Output is correct |
10 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
11 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
12 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
13 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
14 | Correct | 0 ms | 12052 KB | Output is correct |
15 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
16 | Correct | 0 ms | 12052 KB | Output is correct |
17 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
18 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
19 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
20 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
21 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
22 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
23 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
24 | Correct | 0 ms | 12052 KB | Output is correct |
25 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
26 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
27 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
28 | Correct | 0 ms | 12052 KB | Output is correct |
29 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
30 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
31 | Correct | 0 ms | 12052 KB | Output is correct |
32 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
33 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
34 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
35 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
36 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
37 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
38 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
39 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
40 | Correct | 0 ms | 12052 KB | Output is correct |
41 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
42 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
43 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
44 | Correct | 0 ms | 12052 KB | Output is correct |
45 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
46 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
47 | Correct | 0 ms | 12052 KB | Output is correct |
48 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
49 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
50 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
51 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
52 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
53 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 12052 KB | Output is correct |
2 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
3 | Correct | 0 ms | 12052 KB | Output is correct |
4 | Correct | 0 ms | 12052 KB | Output is correct |
5 | Correct | 0 ms | 12052 KB | Output is correct |
6 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
7 | Correct | 0 ms | 12052 KB | Output is correct |
8 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
9 | Correct | 0 ms | 12052 KB | Output is correct |
10 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
11 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
12 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
13 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
14 | Correct | 0 ms | 12052 KB | Output is correct |
15 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
16 | Correct | 0 ms | 12052 KB | Output is correct |
17 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
18 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
19 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
20 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
21 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
22 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
23 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
24 | Correct | 0 ms | 12052 KB | Output is correct |
25 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
26 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
27 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
28 | Correct | 0 ms | 12052 KB | Output is correct |
29 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
30 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
31 | Correct | 0 ms | 12052 KB | Output is correct |
32 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
33 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
34 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
35 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
36 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
37 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
38 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
39 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
40 | Correct | 0 ms | 12052 KB | Output is correct |
41 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
42 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
43 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
44 | Correct | 0 ms | 12052 KB | Output is correct |
45 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
46 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
47 | Correct | 0 ms | 12052 KB | Output is correct |
48 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
49 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
50 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
51 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
52 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
53 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
54 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
55 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
56 | Correct | 6 ms | 12052 KB | Output is correct |
57 | Incorrect | 3 ms | 12052 KB | Output isn't correct |
58 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
59 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
60 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
61 | Correct | 3 ms | 12052 KB | Output is correct |
62 | Incorrect | 3 ms | 12052 KB | Output isn't correct |
63 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
64 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
65 | Correct | 3 ms | 12052 KB | Output is correct |
66 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
67 | Incorrect | 3 ms | 12052 KB | Output isn't correct |
68 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
69 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 12052 KB | Output is correct |
2 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
3 | Correct | 0 ms | 12052 KB | Output is correct |
4 | Correct | 0 ms | 12052 KB | Output is correct |
5 | Correct | 0 ms | 12052 KB | Output is correct |
6 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
7 | Correct | 0 ms | 12052 KB | Output is correct |
8 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
9 | Correct | 0 ms | 12052 KB | Output is correct |
10 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
11 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
12 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
13 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
14 | Correct | 0 ms | 12052 KB | Output is correct |
15 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
16 | Correct | 0 ms | 12052 KB | Output is correct |
17 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
18 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
19 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
20 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
21 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
22 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
23 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
24 | Correct | 0 ms | 12052 KB | Output is correct |
25 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
26 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
27 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
28 | Correct | 0 ms | 12052 KB | Output is correct |
29 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
30 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
31 | Correct | 0 ms | 12052 KB | Output is correct |
32 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
33 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
34 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
35 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
36 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
37 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
38 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
39 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
40 | Correct | 0 ms | 12052 KB | Output is correct |
41 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
42 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
43 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
44 | Correct | 0 ms | 12052 KB | Output is correct |
45 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
46 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
47 | Correct | 0 ms | 12052 KB | Output is correct |
48 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
49 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
50 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
51 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
52 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
53 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
54 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
55 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
56 | Correct | 6 ms | 12052 KB | Output is correct |
57 | Incorrect | 3 ms | 12052 KB | Output isn't correct |
58 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
59 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
60 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
61 | Correct | 3 ms | 12052 KB | Output is correct |
62 | Incorrect | 3 ms | 12052 KB | Output isn't correct |
63 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
64 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
65 | Correct | 3 ms | 12052 KB | Output is correct |
66 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
67 | Incorrect | 3 ms | 12052 KB | Output isn't correct |
68 | Incorrect | 0 ms | 12052 KB | Output isn't correct |
69 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
70 | Incorrect | 6 ms | 12052 KB | Output isn't correct |
71 | Incorrect | 126 ms | 12052 KB | Output isn't correct |
72 | Correct | 93 ms | 12052 KB | Output is correct |
73 | Incorrect | 133 ms | 12052 KB | Output isn't correct |
74 | Correct | 86 ms | 12052 KB | Output is correct |
75 | Incorrect | 129 ms | 12052 KB | Output isn't correct |
76 | Incorrect | 133 ms | 12052 KB | Output isn't correct |
77 | Incorrect | 46 ms | 12052 KB | Output isn't correct |
78 | Incorrect | 129 ms | 12052 KB | Output isn't correct |
79 | Incorrect | 129 ms | 12052 KB | Output isn't correct |
80 | Correct | 109 ms | 12052 KB | Output is correct |
81 | Incorrect | 23 ms | 12052 KB | Output isn't correct |
82 | Incorrect | 89 ms | 12052 KB | Output isn't correct |
83 | Incorrect | 136 ms | 12052 KB | Output isn't correct |
84 | Incorrect | 116 ms | 12052 KB | Output isn't correct |
85 | Incorrect | 133 ms | 12052 KB | Output isn't correct |
86 | Incorrect | 139 ms | 12052 KB | Output isn't correct |
87 | Incorrect | 99 ms | 12052 KB | Output isn't correct |
88 | Incorrect | 13 ms | 12052 KB | Output isn't correct |
89 | Incorrect | 73 ms | 12052 KB | Output isn't correct |
90 | Incorrect | 46 ms | 12052 KB | Output isn't correct |
91 | Incorrect | 3 ms | 12052 KB | Output isn't correct |
92 | Incorrect | 43 ms | 12052 KB | Output isn't correct |