Submission #66212

# Submission time Handle Problem Language Result Execution time Memory
66212 2018-08-10T04:53:46 Z 윤교준(#1888) Can polan into space? (OJUZ11_space) C++11
100 / 100
222 ms 30100 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 200005;

ll B[MAXN], D[MAXN], E[MAXN];
int DR[MAXN], ER[MAXN];
int A[MAXN][3];

ll Ans = -INFLL; int AnsR;
int N;

void f(int idx) {
	int mid = DR[idx];
	if(!mid) {
		for(int i = idx-1; i; i--) printf("%d ", i);
		puts("");
		return;
	}
	int s = ER[mid];
	printf("%d ", s);
	for(int i = s+1; i < mid; i++) printf("%d ", i);
	for(int i = idx-1; mid < i; i--) printf("%d ", i);
	printf("%d ", mid);
	f(s);
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) {
		for(int j = 0; j < 3; j++)
			cin >> A[i][j];
		B[i] = B[i-1] + A[i][1];
	}

	{
		D[0] = -INFLL; E[0] = 0;
		ll dmx = -INFLL, emx = 0;
		int dmxr = 0, emxr = 0;
		for(int i = 1; i <= N; i++) {
			D[i] = B[i-1] + A[i][0] + emx;
			E[i] = (1 == i) ? -INFLL : B[i-1] + A[i][2] + dmx;
			DR[i] = emxr; ER[i] = dmxr;
			if(-INFLL < D[i] && dmx < D[i] - B[i]) {
				dmx = D[i] - B[i];
				dmxr = i;
			}
			if(-INFLL < E[i] && emx < E[i] - B[i]) {
				emx = E[i] - B[i];
				emxr = i;
			}
		}
	}
	for(int i = 1; i <= N; i++) {
		ll t = D[i] + B[N] - B[i];
		if(t <= Ans) continue;
		Ans = t; AnsR = i;
	}
	printf("%lld\n", Ans);
	printf("%d ", AnsR);
	for(int i = AnsR+1; i <= N; i++) printf("%d ", i);
	f(AnsR);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 500 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 548 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 2 ms 612 KB Output is correct
13 Correct 2 ms 644 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 752 KB Output is correct
17 Correct 3 ms 752 KB Output is correct
18 Correct 3 ms 752 KB Output is correct
19 Correct 4 ms 752 KB Output is correct
20 Correct 3 ms 752 KB Output is correct
21 Correct 3 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 500 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 548 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 2 ms 612 KB Output is correct
13 Correct 2 ms 644 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 752 KB Output is correct
17 Correct 3 ms 752 KB Output is correct
18 Correct 3 ms 752 KB Output is correct
19 Correct 4 ms 752 KB Output is correct
20 Correct 3 ms 752 KB Output is correct
21 Correct 3 ms 752 KB Output is correct
22 Correct 3 ms 752 KB Output is correct
23 Correct 2 ms 752 KB Output is correct
24 Correct 3 ms 752 KB Output is correct
25 Correct 3 ms 752 KB Output is correct
26 Correct 2 ms 848 KB Output is correct
27 Correct 3 ms 848 KB Output is correct
28 Correct 2 ms 848 KB Output is correct
29 Correct 3 ms 848 KB Output is correct
30 Correct 2 ms 848 KB Output is correct
31 Correct 2 ms 848 KB Output is correct
32 Correct 3 ms 848 KB Output is correct
33 Correct 3 ms 848 KB Output is correct
34 Correct 2 ms 848 KB Output is correct
35 Correct 2 ms 848 KB Output is correct
36 Correct 2 ms 848 KB Output is correct
37 Correct 3 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 500 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 548 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 2 ms 612 KB Output is correct
13 Correct 2 ms 644 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 752 KB Output is correct
17 Correct 3 ms 752 KB Output is correct
18 Correct 3 ms 752 KB Output is correct
19 Correct 4 ms 752 KB Output is correct
20 Correct 3 ms 752 KB Output is correct
21 Correct 3 ms 752 KB Output is correct
22 Correct 3 ms 752 KB Output is correct
23 Correct 2 ms 752 KB Output is correct
24 Correct 3 ms 752 KB Output is correct
25 Correct 3 ms 752 KB Output is correct
26 Correct 2 ms 848 KB Output is correct
27 Correct 3 ms 848 KB Output is correct
28 Correct 2 ms 848 KB Output is correct
29 Correct 3 ms 848 KB Output is correct
30 Correct 2 ms 848 KB Output is correct
31 Correct 2 ms 848 KB Output is correct
32 Correct 3 ms 848 KB Output is correct
33 Correct 3 ms 848 KB Output is correct
34 Correct 2 ms 848 KB Output is correct
35 Correct 2 ms 848 KB Output is correct
36 Correct 2 ms 848 KB Output is correct
37 Correct 3 ms 848 KB Output is correct
38 Correct 3 ms 848 KB Output is correct
39 Correct 3 ms 848 KB Output is correct
40 Correct 2 ms 848 KB Output is correct
41 Correct 3 ms 848 KB Output is correct
42 Correct 3 ms 848 KB Output is correct
43 Correct 4 ms 880 KB Output is correct
44 Correct 3 ms 880 KB Output is correct
45 Correct 2 ms 880 KB Output is correct
46 Correct 3 ms 880 KB Output is correct
47 Correct 2 ms 880 KB Output is correct
48 Correct 3 ms 928 KB Output is correct
49 Correct 2 ms 1000 KB Output is correct
50 Correct 3 ms 1000 KB Output is correct
51 Correct 3 ms 1000 KB Output is correct
52 Correct 3 ms 1000 KB Output is correct
53 Correct 2 ms 1000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 500 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 548 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 2 ms 612 KB Output is correct
13 Correct 2 ms 644 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 752 KB Output is correct
17 Correct 3 ms 752 KB Output is correct
18 Correct 3 ms 752 KB Output is correct
19 Correct 4 ms 752 KB Output is correct
20 Correct 3 ms 752 KB Output is correct
21 Correct 3 ms 752 KB Output is correct
22 Correct 3 ms 752 KB Output is correct
23 Correct 2 ms 752 KB Output is correct
24 Correct 3 ms 752 KB Output is correct
25 Correct 3 ms 752 KB Output is correct
26 Correct 2 ms 848 KB Output is correct
27 Correct 3 ms 848 KB Output is correct
28 Correct 2 ms 848 KB Output is correct
29 Correct 3 ms 848 KB Output is correct
30 Correct 2 ms 848 KB Output is correct
31 Correct 2 ms 848 KB Output is correct
32 Correct 3 ms 848 KB Output is correct
33 Correct 3 ms 848 KB Output is correct
34 Correct 2 ms 848 KB Output is correct
35 Correct 2 ms 848 KB Output is correct
36 Correct 2 ms 848 KB Output is correct
37 Correct 3 ms 848 KB Output is correct
38 Correct 3 ms 848 KB Output is correct
39 Correct 3 ms 848 KB Output is correct
40 Correct 2 ms 848 KB Output is correct
41 Correct 3 ms 848 KB Output is correct
42 Correct 3 ms 848 KB Output is correct
43 Correct 4 ms 880 KB Output is correct
44 Correct 3 ms 880 KB Output is correct
45 Correct 2 ms 880 KB Output is correct
46 Correct 3 ms 880 KB Output is correct
47 Correct 2 ms 880 KB Output is correct
48 Correct 3 ms 928 KB Output is correct
49 Correct 2 ms 1000 KB Output is correct
50 Correct 3 ms 1000 KB Output is correct
51 Correct 3 ms 1000 KB Output is correct
52 Correct 3 ms 1000 KB Output is correct
53 Correct 2 ms 1000 KB Output is correct
54 Correct 3 ms 1000 KB Output is correct
55 Correct 8 ms 1616 KB Output is correct
56 Correct 7 ms 1636 KB Output is correct
57 Correct 14 ms 1636 KB Output is correct
58 Correct 9 ms 1668 KB Output is correct
59 Correct 8 ms 1684 KB Output is correct
60 Correct 8 ms 1684 KB Output is correct
61 Correct 9 ms 1684 KB Output is correct
62 Correct 9 ms 1684 KB Output is correct
63 Correct 4 ms 1684 KB Output is correct
64 Correct 10 ms 1684 KB Output is correct
65 Correct 8 ms 1700 KB Output is correct
66 Correct 11 ms 1700 KB Output is correct
67 Correct 5 ms 1700 KB Output is correct
68 Correct 6 ms 1700 KB Output is correct
69 Correct 8 ms 1700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 496 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 500 KB Output is correct
8 Correct 2 ms 508 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 548 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 2 ms 612 KB Output is correct
13 Correct 2 ms 644 KB Output is correct
14 Correct 3 ms 644 KB Output is correct
15 Correct 2 ms 692 KB Output is correct
16 Correct 2 ms 752 KB Output is correct
17 Correct 3 ms 752 KB Output is correct
18 Correct 3 ms 752 KB Output is correct
19 Correct 4 ms 752 KB Output is correct
20 Correct 3 ms 752 KB Output is correct
21 Correct 3 ms 752 KB Output is correct
22 Correct 3 ms 752 KB Output is correct
23 Correct 2 ms 752 KB Output is correct
24 Correct 3 ms 752 KB Output is correct
25 Correct 3 ms 752 KB Output is correct
26 Correct 2 ms 848 KB Output is correct
27 Correct 3 ms 848 KB Output is correct
28 Correct 2 ms 848 KB Output is correct
29 Correct 3 ms 848 KB Output is correct
30 Correct 2 ms 848 KB Output is correct
31 Correct 2 ms 848 KB Output is correct
32 Correct 3 ms 848 KB Output is correct
33 Correct 3 ms 848 KB Output is correct
34 Correct 2 ms 848 KB Output is correct
35 Correct 2 ms 848 KB Output is correct
36 Correct 2 ms 848 KB Output is correct
37 Correct 3 ms 848 KB Output is correct
38 Correct 3 ms 848 KB Output is correct
39 Correct 3 ms 848 KB Output is correct
40 Correct 2 ms 848 KB Output is correct
41 Correct 3 ms 848 KB Output is correct
42 Correct 3 ms 848 KB Output is correct
43 Correct 4 ms 880 KB Output is correct
44 Correct 3 ms 880 KB Output is correct
45 Correct 2 ms 880 KB Output is correct
46 Correct 3 ms 880 KB Output is correct
47 Correct 2 ms 880 KB Output is correct
48 Correct 3 ms 928 KB Output is correct
49 Correct 2 ms 1000 KB Output is correct
50 Correct 3 ms 1000 KB Output is correct
51 Correct 3 ms 1000 KB Output is correct
52 Correct 3 ms 1000 KB Output is correct
53 Correct 2 ms 1000 KB Output is correct
54 Correct 3 ms 1000 KB Output is correct
55 Correct 8 ms 1616 KB Output is correct
56 Correct 7 ms 1636 KB Output is correct
57 Correct 14 ms 1636 KB Output is correct
58 Correct 9 ms 1668 KB Output is correct
59 Correct 8 ms 1684 KB Output is correct
60 Correct 8 ms 1684 KB Output is correct
61 Correct 9 ms 1684 KB Output is correct
62 Correct 9 ms 1684 KB Output is correct
63 Correct 4 ms 1684 KB Output is correct
64 Correct 10 ms 1684 KB Output is correct
65 Correct 8 ms 1700 KB Output is correct
66 Correct 11 ms 1700 KB Output is correct
67 Correct 5 ms 1700 KB Output is correct
68 Correct 6 ms 1700 KB Output is correct
69 Correct 8 ms 1700 KB Output is correct
70 Correct 9 ms 1700 KB Output is correct
71 Correct 135 ms 12964 KB Output is correct
72 Correct 135 ms 19408 KB Output is correct
73 Correct 128 ms 25168 KB Output is correct
74 Correct 116 ms 28028 KB Output is correct
75 Correct 141 ms 29956 KB Output is correct
76 Correct 222 ms 29972 KB Output is correct
77 Correct 58 ms 29972 KB Output is correct
78 Correct 129 ms 29972 KB Output is correct
79 Correct 123 ms 29972 KB Output is correct
80 Correct 132 ms 30016 KB Output is correct
81 Correct 28 ms 30016 KB Output is correct
82 Correct 90 ms 30016 KB Output is correct
83 Correct 193 ms 30016 KB Output is correct
84 Correct 118 ms 30100 KB Output is correct
85 Correct 146 ms 30100 KB Output is correct
86 Correct 145 ms 30100 KB Output is correct
87 Correct 152 ms 30100 KB Output is correct
88 Correct 31 ms 30100 KB Output is correct
89 Correct 101 ms 30100 KB Output is correct
90 Correct 49 ms 30100 KB Output is correct
91 Correct 9 ms 30100 KB Output is correct
92 Correct 61 ms 30100 KB Output is correct