답안 #66204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66204 2018-08-10T04:36:57 Z 김세빈(#1887) Can polan into space? (OJUZ11_space) C++11
0 / 100
193 ms 22656 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll D[202020][2], T[202020][2];
ll A[202020], B[202020], C[202020];
deque <ll> P;
ll n;

int main()
{
	ll i, k;
	
	scanf("%lld", &n);
	
	for(i=1; i<=n; i++){
		scanf("%lld%lld%lld", A+i, B+i, C+i);
	}
	
	D[2][0] = A[1];
	D[2][1] = B[1];
	
	for(i=3; i<=n; i++){
		if(D[i-1][0] + B[i-1] > D[i-1][1] + A[i-1]){
			D[i][0] = D[i-1][0] + B[i-1];
			T[i][0] = 0;
		}
		else{
			D[i][0] = D[i-1][1] + A[i-1];
			T[i][0] = 1;
		}
		
		if(D[i-1][0] + C[i-1] > D[i-1][1] + B[i-1]){
			D[i][1] = D[i-1][0] + C[i-1];
			T[i][1] = 0;
		}
		else{
			D[i][1] = D[i-1][1] + B[i-1];
			T[i][1] = 1;
		}
	}
	
	P.push_back(n);
	
	if(D[n][0] + B[n] > D[n][1] + A[n]){
		printf("%lld\n", D[n][0] + B[n]);
		k = 0;
	}
	else{
		printf("%lld\n", D[n][1] + A[n]);
		k = 1;
	}
		
	for(i=n; i>=2; i--){
		if(k == 0) P.push_front(i - 1);
		else P.push_back(i - 1);
		k = T[i][k];
	}
	
	for(ll &t: P) printf("%lld ", t);
	printf("\n");
	
	return 0;
}

Compilation message

space.cpp: In function 'int main()':
space.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
space.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", A+i, B+i, C+i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 3 ms 516 KB Output is correct
6 Correct 3 ms 580 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 636 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 656 KB Output is correct
14 Correct 3 ms 660 KB Output is correct
15 Correct 2 ms 660 KB Output is correct
16 Correct 2 ms 668 KB Output is correct
17 Correct 4 ms 672 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 3 ms 680 KB Output is correct
20 Correct 2 ms 680 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 3 ms 516 KB Output is correct
6 Correct 3 ms 580 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 636 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 656 KB Output is correct
14 Correct 3 ms 660 KB Output is correct
15 Correct 2 ms 660 KB Output is correct
16 Correct 2 ms 668 KB Output is correct
17 Correct 4 ms 672 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 3 ms 680 KB Output is correct
20 Correct 2 ms 680 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 3 ms 732 KB Output is correct
25 Correct 3 ms 740 KB Output is correct
26 Correct 2 ms 740 KB Output is correct
27 Correct 3 ms 748 KB Output is correct
28 Correct 2 ms 748 KB Output is correct
29 Correct 3 ms 752 KB Output is correct
30 Correct 3 ms 756 KB Output is correct
31 Correct 2 ms 760 KB Output is correct
32 Correct 2 ms 764 KB Output is correct
33 Correct 3 ms 768 KB Output is correct
34 Correct 3 ms 772 KB Output is correct
35 Correct 2 ms 776 KB Output is correct
36 Correct 4 ms 784 KB Output is correct
37 Correct 3 ms 784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 3 ms 516 KB Output is correct
6 Correct 3 ms 580 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 636 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 656 KB Output is correct
14 Correct 3 ms 660 KB Output is correct
15 Correct 2 ms 660 KB Output is correct
16 Correct 2 ms 668 KB Output is correct
17 Correct 4 ms 672 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 3 ms 680 KB Output is correct
20 Correct 2 ms 680 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 3 ms 732 KB Output is correct
25 Correct 3 ms 740 KB Output is correct
26 Correct 2 ms 740 KB Output is correct
27 Correct 3 ms 748 KB Output is correct
28 Correct 2 ms 748 KB Output is correct
29 Correct 3 ms 752 KB Output is correct
30 Correct 3 ms 756 KB Output is correct
31 Correct 2 ms 760 KB Output is correct
32 Correct 2 ms 764 KB Output is correct
33 Correct 3 ms 768 KB Output is correct
34 Correct 3 ms 772 KB Output is correct
35 Correct 2 ms 776 KB Output is correct
36 Correct 4 ms 784 KB Output is correct
37 Correct 3 ms 784 KB Output is correct
38 Correct 2 ms 788 KB Output is correct
39 Correct 3 ms 792 KB Output is correct
40 Correct 3 ms 808 KB Output is correct
41 Correct 3 ms 816 KB Output is correct
42 Correct 3 ms 828 KB Output is correct
43 Correct 3 ms 840 KB Output is correct
44 Correct 2 ms 852 KB Output is correct
45 Correct 3 ms 864 KB Output is correct
46 Correct 2 ms 872 KB Output is correct
47 Correct 3 ms 880 KB Output is correct
48 Correct 3 ms 896 KB Output is correct
49 Correct 4 ms 904 KB Output is correct
50 Correct 2 ms 916 KB Output is correct
51 Correct 3 ms 924 KB Output is correct
52 Correct 3 ms 932 KB Output is correct
53 Correct 4 ms 1008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 3 ms 516 KB Output is correct
6 Correct 3 ms 580 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 636 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 656 KB Output is correct
14 Correct 3 ms 660 KB Output is correct
15 Correct 2 ms 660 KB Output is correct
16 Correct 2 ms 668 KB Output is correct
17 Correct 4 ms 672 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 3 ms 680 KB Output is correct
20 Correct 2 ms 680 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 3 ms 732 KB Output is correct
25 Correct 3 ms 740 KB Output is correct
26 Correct 2 ms 740 KB Output is correct
27 Correct 3 ms 748 KB Output is correct
28 Correct 2 ms 748 KB Output is correct
29 Correct 3 ms 752 KB Output is correct
30 Correct 3 ms 756 KB Output is correct
31 Correct 2 ms 760 KB Output is correct
32 Correct 2 ms 764 KB Output is correct
33 Correct 3 ms 768 KB Output is correct
34 Correct 3 ms 772 KB Output is correct
35 Correct 2 ms 776 KB Output is correct
36 Correct 4 ms 784 KB Output is correct
37 Correct 3 ms 784 KB Output is correct
38 Correct 2 ms 788 KB Output is correct
39 Correct 3 ms 792 KB Output is correct
40 Correct 3 ms 808 KB Output is correct
41 Correct 3 ms 816 KB Output is correct
42 Correct 3 ms 828 KB Output is correct
43 Correct 3 ms 840 KB Output is correct
44 Correct 2 ms 852 KB Output is correct
45 Correct 3 ms 864 KB Output is correct
46 Correct 2 ms 872 KB Output is correct
47 Correct 3 ms 880 KB Output is correct
48 Correct 3 ms 896 KB Output is correct
49 Correct 4 ms 904 KB Output is correct
50 Correct 2 ms 916 KB Output is correct
51 Correct 3 ms 924 KB Output is correct
52 Correct 3 ms 932 KB Output is correct
53 Correct 4 ms 1008 KB Output is correct
54 Correct 3 ms 1008 KB Output is correct
55 Correct 10 ms 1864 KB Output is correct
56 Correct 12 ms 2156 KB Output is correct
57 Correct 10 ms 2464 KB Output is correct
58 Correct 12 ms 2780 KB Output is correct
59 Correct 11 ms 3064 KB Output is correct
60 Correct 11 ms 3408 KB Output is correct
61 Correct 10 ms 3792 KB Output is correct
62 Correct 8 ms 3792 KB Output is correct
63 Correct 4 ms 3792 KB Output is correct
64 Correct 11 ms 4252 KB Output is correct
65 Correct 8 ms 4416 KB Output is correct
66 Correct 15 ms 4708 KB Output is correct
67 Correct 7 ms 4708 KB Output is correct
68 Correct 6 ms 4708 KB Output is correct
69 Correct 10 ms 5356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 3 ms 516 KB Output is correct
6 Correct 3 ms 580 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 3 ms 636 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 2 ms 648 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 656 KB Output is correct
14 Correct 3 ms 660 KB Output is correct
15 Correct 2 ms 660 KB Output is correct
16 Correct 2 ms 668 KB Output is correct
17 Correct 4 ms 672 KB Output is correct
18 Correct 2 ms 676 KB Output is correct
19 Correct 3 ms 680 KB Output is correct
20 Correct 2 ms 680 KB Output is correct
21 Correct 2 ms 688 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 3 ms 732 KB Output is correct
25 Correct 3 ms 740 KB Output is correct
26 Correct 2 ms 740 KB Output is correct
27 Correct 3 ms 748 KB Output is correct
28 Correct 2 ms 748 KB Output is correct
29 Correct 3 ms 752 KB Output is correct
30 Correct 3 ms 756 KB Output is correct
31 Correct 2 ms 760 KB Output is correct
32 Correct 2 ms 764 KB Output is correct
33 Correct 3 ms 768 KB Output is correct
34 Correct 3 ms 772 KB Output is correct
35 Correct 2 ms 776 KB Output is correct
36 Correct 4 ms 784 KB Output is correct
37 Correct 3 ms 784 KB Output is correct
38 Correct 2 ms 788 KB Output is correct
39 Correct 3 ms 792 KB Output is correct
40 Correct 3 ms 808 KB Output is correct
41 Correct 3 ms 816 KB Output is correct
42 Correct 3 ms 828 KB Output is correct
43 Correct 3 ms 840 KB Output is correct
44 Correct 2 ms 852 KB Output is correct
45 Correct 3 ms 864 KB Output is correct
46 Correct 2 ms 872 KB Output is correct
47 Correct 3 ms 880 KB Output is correct
48 Correct 3 ms 896 KB Output is correct
49 Correct 4 ms 904 KB Output is correct
50 Correct 2 ms 916 KB Output is correct
51 Correct 3 ms 924 KB Output is correct
52 Correct 3 ms 932 KB Output is correct
53 Correct 4 ms 1008 KB Output is correct
54 Correct 3 ms 1008 KB Output is correct
55 Correct 10 ms 1864 KB Output is correct
56 Correct 12 ms 2156 KB Output is correct
57 Correct 10 ms 2464 KB Output is correct
58 Correct 12 ms 2780 KB Output is correct
59 Correct 11 ms 3064 KB Output is correct
60 Correct 11 ms 3408 KB Output is correct
61 Correct 10 ms 3792 KB Output is correct
62 Correct 8 ms 3792 KB Output is correct
63 Correct 4 ms 3792 KB Output is correct
64 Correct 11 ms 4252 KB Output is correct
65 Correct 8 ms 4416 KB Output is correct
66 Correct 15 ms 4708 KB Output is correct
67 Correct 7 ms 4708 KB Output is correct
68 Correct 6 ms 4708 KB Output is correct
69 Correct 10 ms 5356 KB Output is correct
70 Correct 11 ms 5520 KB Output is correct
71 Correct 152 ms 22536 KB Output is correct
72 Correct 137 ms 22548 KB Output is correct
73 Correct 150 ms 22548 KB Output is correct
74 Correct 119 ms 22548 KB Output is correct
75 Correct 193 ms 22548 KB Output is correct
76 Correct 147 ms 22548 KB Output is correct
77 Correct 65 ms 22548 KB Output is correct
78 Correct 157 ms 22548 KB Output is correct
79 Correct 149 ms 22564 KB Output is correct
80 Correct 133 ms 22564 KB Output is correct
81 Correct 33 ms 22564 KB Output is correct
82 Correct 105 ms 22564 KB Output is correct
83 Correct 164 ms 22564 KB Output is correct
84 Correct 154 ms 22564 KB Output is correct
85 Correct 151 ms 22564 KB Output is correct
86 Correct 141 ms 22656 KB Output is correct
87 Correct 149 ms 22656 KB Output is correct
88 Correct 28 ms 22656 KB Output is correct
89 Correct 88 ms 22656 KB Output is correct
90 Correct 60 ms 22656 KB Output is correct
91 Correct 8 ms 22656 KB Output is correct
92 Correct 77 ms 22656 KB Output is correct