Submission #20431

# Submission time Handle Problem Language Result Execution time Memory
20431 2017-02-11T13:02:30 Z CodingBug(#51, CodingBug) Can polan into space? (OJUZ11_space) C++
0 / 100
129 ms 9052 KB
#include <bits/stdc++.h>
#define M 200000
using namespace std;
int d[M+1][2],n,a[M+1][3];
int p[M+1][2],l,r,ans[M*2+1];

void input(void){
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
}

void process(void){
	int i,j;
	d[1][0]=-1e9;
	d[1][1]=0;
	for(i=2;i<=n;i++){
		int lf=d[i-1][0]+a[i-1][1],rf=d[i-1][1]+a[i-1][0];
		if(lf>rf){
			d[i][0]=lf;
			p[i][0]=0;
		}else{
			d[i][0]=rf;
			p[i][0]=1;
		}
		lf=d[i-1][0]+a[i-1][2],rf=d[i-1][1]+a[i-1][1];
		if(lf>rf){
			d[i][1]=lf;
			p[i][1]=0;
		}else{
			d[i][1]=rf;
			p[i][1]=1;
		}
	}
	int x;
	if(d[n][0]+a[n][1]>d[n][1]+a[n][0]){
		printf("%d\n",d[n][0]+a[n][1]);
		x=0;
	}else{
		printf("%d\n",d[n][1]+a[n][0]);
		x=1;
	}
	l=r=n;
	ans[n]=n;
	for(i=n;i>1;i--){
		if(x){
			ans[++r]=i-1;
		}else{
			ans[--l]=i-1;
		}
		x=p[i][x];
	}
	for(i=l;i<=r;i++) printf("%d ",ans[i]);
}

int main(){
//	freopen("input.txt","r",stdin);

	input();
	process();

	return 0;
}

Compilation message

space.cpp: In function 'void process()':
space.cpp:14:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j;
        ^
space.cpp: In function 'void input()':
space.cpp:9:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
space.cpp:10:64: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
                                                                ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9052 KB Output is correct
2 Incorrect 0 ms 9052 KB Output isn't correct
3 Incorrect 0 ms 9052 KB Output isn't correct
4 Incorrect 0 ms 9052 KB Output isn't correct
5 Correct 0 ms 9052 KB Output is correct
6 Incorrect 0 ms 9052 KB Output isn't correct
7 Correct 0 ms 9052 KB Output is correct
8 Incorrect 0 ms 9052 KB Output isn't correct
9 Incorrect 0 ms 9052 KB Output isn't correct
10 Incorrect 0 ms 9052 KB Output isn't correct
11 Incorrect 0 ms 9052 KB Output isn't correct
12 Incorrect 0 ms 9052 KB Output isn't correct
13 Incorrect 0 ms 9052 KB Output isn't correct
14 Correct 0 ms 9052 KB Output is correct
15 Incorrect 0 ms 9052 KB Output isn't correct
16 Incorrect 0 ms 9052 KB Output isn't correct
17 Incorrect 0 ms 9052 KB Output isn't correct
18 Incorrect 0 ms 9052 KB Output isn't correct
19 Incorrect 0 ms 9052 KB Output isn't correct
20 Incorrect 0 ms 9052 KB Output isn't correct
21 Incorrect 0 ms 9052 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9052 KB Output is correct
2 Incorrect 0 ms 9052 KB Output isn't correct
3 Incorrect 0 ms 9052 KB Output isn't correct
4 Incorrect 0 ms 9052 KB Output isn't correct
5 Correct 0 ms 9052 KB Output is correct
6 Incorrect 0 ms 9052 KB Output isn't correct
7 Correct 0 ms 9052 KB Output is correct
8 Incorrect 0 ms 9052 KB Output isn't correct
9 Incorrect 0 ms 9052 KB Output isn't correct
10 Incorrect 0 ms 9052 KB Output isn't correct
11 Incorrect 0 ms 9052 KB Output isn't correct
12 Incorrect 0 ms 9052 KB Output isn't correct
13 Incorrect 0 ms 9052 KB Output isn't correct
14 Correct 0 ms 9052 KB Output is correct
15 Incorrect 0 ms 9052 KB Output isn't correct
16 Incorrect 0 ms 9052 KB Output isn't correct
17 Incorrect 0 ms 9052 KB Output isn't correct
18 Incorrect 0 ms 9052 KB Output isn't correct
19 Incorrect 0 ms 9052 KB Output isn't correct
20 Incorrect 0 ms 9052 KB Output isn't correct
21 Incorrect 0 ms 9052 KB Output isn't correct
22 Incorrect 0 ms 9052 KB Output isn't correct
23 Incorrect 0 ms 9052 KB Output isn't correct
24 Incorrect 0 ms 9052 KB Output isn't correct
25 Incorrect 0 ms 9052 KB Output isn't correct
26 Incorrect 0 ms 9052 KB Output isn't correct
27 Incorrect 0 ms 9052 KB Output isn't correct
28 Incorrect 0 ms 9052 KB Output isn't correct
29 Incorrect 0 ms 9052 KB Output isn't correct
30 Incorrect 0 ms 9052 KB Output isn't correct
31 Incorrect 0 ms 9052 KB Output isn't correct
32 Incorrect 0 ms 9052 KB Output isn't correct
33 Incorrect 0 ms 9052 KB Output isn't correct
34 Incorrect 0 ms 9052 KB Output isn't correct
35 Incorrect 0 ms 9052 KB Output isn't correct
36 Incorrect 0 ms 9052 KB Output isn't correct
37 Incorrect 0 ms 9052 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9052 KB Output is correct
2 Incorrect 0 ms 9052 KB Output isn't correct
3 Incorrect 0 ms 9052 KB Output isn't correct
4 Incorrect 0 ms 9052 KB Output isn't correct
5 Correct 0 ms 9052 KB Output is correct
6 Incorrect 0 ms 9052 KB Output isn't correct
7 Correct 0 ms 9052 KB Output is correct
8 Incorrect 0 ms 9052 KB Output isn't correct
9 Incorrect 0 ms 9052 KB Output isn't correct
10 Incorrect 0 ms 9052 KB Output isn't correct
11 Incorrect 0 ms 9052 KB Output isn't correct
12 Incorrect 0 ms 9052 KB Output isn't correct
13 Incorrect 0 ms 9052 KB Output isn't correct
14 Correct 0 ms 9052 KB Output is correct
15 Incorrect 0 ms 9052 KB Output isn't correct
16 Incorrect 0 ms 9052 KB Output isn't correct
17 Incorrect 0 ms 9052 KB Output isn't correct
18 Incorrect 0 ms 9052 KB Output isn't correct
19 Incorrect 0 ms 9052 KB Output isn't correct
20 Incorrect 0 ms 9052 KB Output isn't correct
21 Incorrect 0 ms 9052 KB Output isn't correct
22 Incorrect 0 ms 9052 KB Output isn't correct
23 Incorrect 0 ms 9052 KB Output isn't correct
24 Incorrect 0 ms 9052 KB Output isn't correct
25 Incorrect 0 ms 9052 KB Output isn't correct
26 Incorrect 0 ms 9052 KB Output isn't correct
27 Incorrect 0 ms 9052 KB Output isn't correct
28 Incorrect 0 ms 9052 KB Output isn't correct
29 Incorrect 0 ms 9052 KB Output isn't correct
30 Incorrect 0 ms 9052 KB Output isn't correct
31 Incorrect 0 ms 9052 KB Output isn't correct
32 Incorrect 0 ms 9052 KB Output isn't correct
33 Incorrect 0 ms 9052 KB Output isn't correct
34 Incorrect 0 ms 9052 KB Output isn't correct
35 Incorrect 0 ms 9052 KB Output isn't correct
36 Incorrect 0 ms 9052 KB Output isn't correct
37 Incorrect 0 ms 9052 KB Output isn't correct
38 Incorrect 0 ms 9052 KB Output isn't correct
39 Incorrect 0 ms 9052 KB Output isn't correct
40 Incorrect 0 ms 9052 KB Output isn't correct
41 Incorrect 0 ms 9052 KB Output isn't correct
42 Incorrect 0 ms 9052 KB Output isn't correct
43 Incorrect 0 ms 9052 KB Output isn't correct
44 Incorrect 0 ms 9052 KB Output isn't correct
45 Incorrect 0 ms 9052 KB Output isn't correct
46 Incorrect 0 ms 9052 KB Output isn't correct
47 Incorrect 0 ms 9052 KB Output isn't correct
48 Incorrect 0 ms 9052 KB Output isn't correct
49 Incorrect 0 ms 9052 KB Output isn't correct
50 Incorrect 0 ms 9052 KB Output isn't correct
51 Incorrect 0 ms 9052 KB Output isn't correct
52 Incorrect 0 ms 9052 KB Output isn't correct
53 Incorrect 0 ms 9052 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9052 KB Output is correct
2 Incorrect 0 ms 9052 KB Output isn't correct
3 Incorrect 0 ms 9052 KB Output isn't correct
4 Incorrect 0 ms 9052 KB Output isn't correct
5 Correct 0 ms 9052 KB Output is correct
6 Incorrect 0 ms 9052 KB Output isn't correct
7 Correct 0 ms 9052 KB Output is correct
8 Incorrect 0 ms 9052 KB Output isn't correct
9 Incorrect 0 ms 9052 KB Output isn't correct
10 Incorrect 0 ms 9052 KB Output isn't correct
11 Incorrect 0 ms 9052 KB Output isn't correct
12 Incorrect 0 ms 9052 KB Output isn't correct
13 Incorrect 0 ms 9052 KB Output isn't correct
14 Correct 0 ms 9052 KB Output is correct
15 Incorrect 0 ms 9052 KB Output isn't correct
16 Incorrect 0 ms 9052 KB Output isn't correct
17 Incorrect 0 ms 9052 KB Output isn't correct
18 Incorrect 0 ms 9052 KB Output isn't correct
19 Incorrect 0 ms 9052 KB Output isn't correct
20 Incorrect 0 ms 9052 KB Output isn't correct
21 Incorrect 0 ms 9052 KB Output isn't correct
22 Incorrect 0 ms 9052 KB Output isn't correct
23 Incorrect 0 ms 9052 KB Output isn't correct
24 Incorrect 0 ms 9052 KB Output isn't correct
25 Incorrect 0 ms 9052 KB Output isn't correct
26 Incorrect 0 ms 9052 KB Output isn't correct
27 Incorrect 0 ms 9052 KB Output isn't correct
28 Incorrect 0 ms 9052 KB Output isn't correct
29 Incorrect 0 ms 9052 KB Output isn't correct
30 Incorrect 0 ms 9052 KB Output isn't correct
31 Incorrect 0 ms 9052 KB Output isn't correct
32 Incorrect 0 ms 9052 KB Output isn't correct
33 Incorrect 0 ms 9052 KB Output isn't correct
34 Incorrect 0 ms 9052 KB Output isn't correct
35 Incorrect 0 ms 9052 KB Output isn't correct
36 Incorrect 0 ms 9052 KB Output isn't correct
37 Incorrect 0 ms 9052 KB Output isn't correct
38 Incorrect 0 ms 9052 KB Output isn't correct
39 Incorrect 0 ms 9052 KB Output isn't correct
40 Incorrect 0 ms 9052 KB Output isn't correct
41 Incorrect 0 ms 9052 KB Output isn't correct
42 Incorrect 0 ms 9052 KB Output isn't correct
43 Incorrect 0 ms 9052 KB Output isn't correct
44 Incorrect 0 ms 9052 KB Output isn't correct
45 Incorrect 0 ms 9052 KB Output isn't correct
46 Incorrect 0 ms 9052 KB Output isn't correct
47 Incorrect 0 ms 9052 KB Output isn't correct
48 Incorrect 0 ms 9052 KB Output isn't correct
49 Incorrect 0 ms 9052 KB Output isn't correct
50 Incorrect 0 ms 9052 KB Output isn't correct
51 Incorrect 0 ms 9052 KB Output isn't correct
52 Incorrect 0 ms 9052 KB Output isn't correct
53 Incorrect 0 ms 9052 KB Output isn't correct
54 Incorrect 0 ms 9052 KB Output isn't correct
55 Incorrect 6 ms 9052 KB Output isn't correct
56 Incorrect 6 ms 9052 KB Output isn't correct
57 Incorrect 3 ms 9052 KB Output isn't correct
58 Incorrect 6 ms 9052 KB Output isn't correct
59 Incorrect 6 ms 9052 KB Output isn't correct
60 Incorrect 6 ms 9052 KB Output isn't correct
61 Incorrect 6 ms 9052 KB Output isn't correct
62 Incorrect 3 ms 9052 KB Output isn't correct
63 Incorrect 0 ms 9052 KB Output isn't correct
64 Incorrect 6 ms 9052 KB Output isn't correct
65 Incorrect 3 ms 9052 KB Output isn't correct
66 Incorrect 6 ms 9052 KB Output isn't correct
67 Incorrect 3 ms 9052 KB Output isn't correct
68 Incorrect 0 ms 9052 KB Output isn't correct
69 Incorrect 6 ms 9052 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9052 KB Output is correct
2 Incorrect 0 ms 9052 KB Output isn't correct
3 Incorrect 0 ms 9052 KB Output isn't correct
4 Incorrect 0 ms 9052 KB Output isn't correct
5 Correct 0 ms 9052 KB Output is correct
6 Incorrect 0 ms 9052 KB Output isn't correct
7 Correct 0 ms 9052 KB Output is correct
8 Incorrect 0 ms 9052 KB Output isn't correct
9 Incorrect 0 ms 9052 KB Output isn't correct
10 Incorrect 0 ms 9052 KB Output isn't correct
11 Incorrect 0 ms 9052 KB Output isn't correct
12 Incorrect 0 ms 9052 KB Output isn't correct
13 Incorrect 0 ms 9052 KB Output isn't correct
14 Correct 0 ms 9052 KB Output is correct
15 Incorrect 0 ms 9052 KB Output isn't correct
16 Incorrect 0 ms 9052 KB Output isn't correct
17 Incorrect 0 ms 9052 KB Output isn't correct
18 Incorrect 0 ms 9052 KB Output isn't correct
19 Incorrect 0 ms 9052 KB Output isn't correct
20 Incorrect 0 ms 9052 KB Output isn't correct
21 Incorrect 0 ms 9052 KB Output isn't correct
22 Incorrect 0 ms 9052 KB Output isn't correct
23 Incorrect 0 ms 9052 KB Output isn't correct
24 Incorrect 0 ms 9052 KB Output isn't correct
25 Incorrect 0 ms 9052 KB Output isn't correct
26 Incorrect 0 ms 9052 KB Output isn't correct
27 Incorrect 0 ms 9052 KB Output isn't correct
28 Incorrect 0 ms 9052 KB Output isn't correct
29 Incorrect 0 ms 9052 KB Output isn't correct
30 Incorrect 0 ms 9052 KB Output isn't correct
31 Incorrect 0 ms 9052 KB Output isn't correct
32 Incorrect 0 ms 9052 KB Output isn't correct
33 Incorrect 0 ms 9052 KB Output isn't correct
34 Incorrect 0 ms 9052 KB Output isn't correct
35 Incorrect 0 ms 9052 KB Output isn't correct
36 Incorrect 0 ms 9052 KB Output isn't correct
37 Incorrect 0 ms 9052 KB Output isn't correct
38 Incorrect 0 ms 9052 KB Output isn't correct
39 Incorrect 0 ms 9052 KB Output isn't correct
40 Incorrect 0 ms 9052 KB Output isn't correct
41 Incorrect 0 ms 9052 KB Output isn't correct
42 Incorrect 0 ms 9052 KB Output isn't correct
43 Incorrect 0 ms 9052 KB Output isn't correct
44 Incorrect 0 ms 9052 KB Output isn't correct
45 Incorrect 0 ms 9052 KB Output isn't correct
46 Incorrect 0 ms 9052 KB Output isn't correct
47 Incorrect 0 ms 9052 KB Output isn't correct
48 Incorrect 0 ms 9052 KB Output isn't correct
49 Incorrect 0 ms 9052 KB Output isn't correct
50 Incorrect 0 ms 9052 KB Output isn't correct
51 Incorrect 0 ms 9052 KB Output isn't correct
52 Incorrect 0 ms 9052 KB Output isn't correct
53 Incorrect 0 ms 9052 KB Output isn't correct
54 Incorrect 0 ms 9052 KB Output isn't correct
55 Incorrect 6 ms 9052 KB Output isn't correct
56 Incorrect 6 ms 9052 KB Output isn't correct
57 Incorrect 3 ms 9052 KB Output isn't correct
58 Incorrect 6 ms 9052 KB Output isn't correct
59 Incorrect 6 ms 9052 KB Output isn't correct
60 Incorrect 6 ms 9052 KB Output isn't correct
61 Incorrect 6 ms 9052 KB Output isn't correct
62 Incorrect 3 ms 9052 KB Output isn't correct
63 Incorrect 0 ms 9052 KB Output isn't correct
64 Incorrect 6 ms 9052 KB Output isn't correct
65 Incorrect 3 ms 9052 KB Output isn't correct
66 Incorrect 6 ms 9052 KB Output isn't correct
67 Incorrect 3 ms 9052 KB Output isn't correct
68 Incorrect 0 ms 9052 KB Output isn't correct
69 Incorrect 6 ms 9052 KB Output isn't correct
70 Incorrect 9 ms 9052 KB Output isn't correct
71 Incorrect 123 ms 9052 KB Output isn't correct
72 Incorrect 99 ms 9052 KB Output isn't correct
73 Incorrect 123 ms 9052 KB Output isn't correct
74 Incorrect 79 ms 9052 KB Output isn't correct
75 Incorrect 129 ms 9052 KB Output isn't correct
76 Incorrect 119 ms 9052 KB Output isn't correct
77 Incorrect 46 ms 9052 KB Output isn't correct
78 Incorrect 119 ms 9052 KB Output isn't correct
79 Incorrect 119 ms 9052 KB Output isn't correct
80 Incorrect 123 ms 9052 KB Output isn't correct
81 Incorrect 19 ms 9052 KB Output isn't correct
82 Incorrect 83 ms 9052 KB Output isn't correct
83 Incorrect 116 ms 9052 KB Output isn't correct
84 Incorrect 119 ms 9052 KB Output isn't correct
85 Incorrect 129 ms 9052 KB Output isn't correct
86 Incorrect 119 ms 9052 KB Output isn't correct
87 Incorrect 123 ms 9052 KB Output isn't correct
88 Incorrect 19 ms 9052 KB Output isn't correct
89 Incorrect 69 ms 9052 KB Output isn't correct
90 Incorrect 33 ms 9052 KB Output isn't correct
91 Incorrect 0 ms 9052 KB Output isn't correct
92 Incorrect 43 ms 9052 KB Output isn't correct