답안 #20626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20626 2017-02-12T17:29:10 Z Where is my GPA?(#45, jun6873) Can polan into space? (OJUZ11_space) C++14
46 / 100
63 ms 6356 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long lint;

const int maxn = 304;

int n, a[maxn], b[maxn], c[maxn], ans[maxn][maxn][4];
lint m[maxn][maxn][4];

void update(int x, int y, int z, lint k, int p) {
	if (m[x][y][z] < k) {
		m[x][y][z] = k;
		ans[x][y][z] = p;
	}
}

lint dp(int x, int y, int z) {
	if (x>y) return 0;

	lint& ret = m[x][y][z];
	if (ret) return ret;

	update(x, y, z, ((z&1) ? b[x] : a[x]) + dp(x+1, y, (z&2)|1), x);
	update(x, y, z, ((z&2) ? b[y] : a[y]) + dp(x, y-1, (z&1)|2), y);
	for (int i=x+1; i<y; i++) update(x, y, z, dp(x, i-1, (z&1)|2) + a[i] + dp(i+1, y, (z&2)|1), i);

	return ret;
}

void redo(int x, int y, int z) {
	if (x>y) return;

	int now = ans[x][y][z];
	printf("%d ", now+1);
	redo(x, now-1, (z&1)|2);
	redo(now+1, y, (z&2)|1);
}

int main()
{
	scanf("%d", &n);
	for (int i=0; i<n; i++) scanf("%d%d%d", a+i, b+i, c+i);
	c[0] = b[0]; c[n-1] = b[n-1];
	b[0] = a[0]; b[n-1] = a[n-1];

	if (n==1) { printf("%d\n1", a[0]); return 0; }

	for (int i=0; i<n; i++) for (int k=0; k<4; k++) update(i, i, k, c[i], i);

	printf("%lld\n", dp(0, n-1, 0));
	redo(0, n-1, 0);
}

Compilation message

space.cpp: In function 'int main()':
space.cpp:42:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
space.cpp:43:56: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=0; i<n; i++) scanf("%d%d%d", a+i, b+i, c+i);
                                                        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6356 KB Output is correct
2 Correct 0 ms 6356 KB Output is correct
3 Correct 0 ms 6356 KB Output is correct
4 Correct 0 ms 6356 KB Output is correct
5 Correct 0 ms 6356 KB Output is correct
6 Correct 0 ms 6356 KB Output is correct
7 Correct 0 ms 6356 KB Output is correct
8 Correct 0 ms 6356 KB Output is correct
9 Correct 0 ms 6356 KB Output is correct
10 Correct 0 ms 6356 KB Output is correct
11 Correct 0 ms 6356 KB Output is correct
12 Correct 0 ms 6356 KB Output is correct
13 Correct 0 ms 6356 KB Output is correct
14 Correct 0 ms 6356 KB Output is correct
15 Correct 0 ms 6356 KB Output is correct
16 Correct 0 ms 6356 KB Output is correct
17 Correct 0 ms 6356 KB Output is correct
18 Correct 0 ms 6356 KB Output is correct
19 Correct 0 ms 6356 KB Output is correct
20 Correct 0 ms 6356 KB Output is correct
21 Correct 0 ms 6356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6356 KB Output is correct
2 Correct 0 ms 6356 KB Output is correct
3 Correct 0 ms 6356 KB Output is correct
4 Correct 0 ms 6356 KB Output is correct
5 Correct 0 ms 6356 KB Output is correct
6 Correct 0 ms 6356 KB Output is correct
7 Correct 0 ms 6356 KB Output is correct
8 Correct 0 ms 6356 KB Output is correct
9 Correct 0 ms 6356 KB Output is correct
10 Correct 0 ms 6356 KB Output is correct
11 Correct 0 ms 6356 KB Output is correct
12 Correct 0 ms 6356 KB Output is correct
13 Correct 0 ms 6356 KB Output is correct
14 Correct 0 ms 6356 KB Output is correct
15 Correct 0 ms 6356 KB Output is correct
16 Correct 0 ms 6356 KB Output is correct
17 Correct 0 ms 6356 KB Output is correct
18 Correct 0 ms 6356 KB Output is correct
19 Correct 0 ms 6356 KB Output is correct
20 Correct 0 ms 6356 KB Output is correct
21 Correct 0 ms 6356 KB Output is correct
22 Correct 0 ms 6356 KB Output is correct
23 Correct 0 ms 6356 KB Output is correct
24 Correct 0 ms 6356 KB Output is correct
25 Correct 0 ms 6356 KB Output is correct
26 Correct 0 ms 6356 KB Output is correct
27 Correct 0 ms 6356 KB Output is correct
28 Correct 0 ms 6356 KB Output is correct
29 Correct 0 ms 6356 KB Output is correct
30 Correct 0 ms 6356 KB Output is correct
31 Correct 0 ms 6356 KB Output is correct
32 Correct 0 ms 6356 KB Output is correct
33 Correct 0 ms 6356 KB Output is correct
34 Correct 0 ms 6356 KB Output is correct
35 Correct 0 ms 6356 KB Output is correct
36 Correct 0 ms 6356 KB Output is correct
37 Correct 0 ms 6356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6356 KB Output is correct
2 Correct 0 ms 6356 KB Output is correct
3 Correct 0 ms 6356 KB Output is correct
4 Correct 0 ms 6356 KB Output is correct
5 Correct 0 ms 6356 KB Output is correct
6 Correct 0 ms 6356 KB Output is correct
7 Correct 0 ms 6356 KB Output is correct
8 Correct 0 ms 6356 KB Output is correct
9 Correct 0 ms 6356 KB Output is correct
10 Correct 0 ms 6356 KB Output is correct
11 Correct 0 ms 6356 KB Output is correct
12 Correct 0 ms 6356 KB Output is correct
13 Correct 0 ms 6356 KB Output is correct
14 Correct 0 ms 6356 KB Output is correct
15 Correct 0 ms 6356 KB Output is correct
16 Correct 0 ms 6356 KB Output is correct
17 Correct 0 ms 6356 KB Output is correct
18 Correct 0 ms 6356 KB Output is correct
19 Correct 0 ms 6356 KB Output is correct
20 Correct 0 ms 6356 KB Output is correct
21 Correct 0 ms 6356 KB Output is correct
22 Correct 0 ms 6356 KB Output is correct
23 Correct 0 ms 6356 KB Output is correct
24 Correct 0 ms 6356 KB Output is correct
25 Correct 0 ms 6356 KB Output is correct
26 Correct 0 ms 6356 KB Output is correct
27 Correct 0 ms 6356 KB Output is correct
28 Correct 0 ms 6356 KB Output is correct
29 Correct 0 ms 6356 KB Output is correct
30 Correct 0 ms 6356 KB Output is correct
31 Correct 0 ms 6356 KB Output is correct
32 Correct 0 ms 6356 KB Output is correct
33 Correct 0 ms 6356 KB Output is correct
34 Correct 0 ms 6356 KB Output is correct
35 Correct 0 ms 6356 KB Output is correct
36 Correct 0 ms 6356 KB Output is correct
37 Correct 0 ms 6356 KB Output is correct
38 Correct 0 ms 6356 KB Output is correct
39 Correct 36 ms 6356 KB Output is correct
40 Correct 39 ms 6356 KB Output is correct
41 Correct 36 ms 6356 KB Output is correct
42 Correct 36 ms 6356 KB Output is correct
43 Correct 43 ms 6356 KB Output is correct
44 Correct 46 ms 6356 KB Output is correct
45 Correct 36 ms 6356 KB Output is correct
46 Correct 26 ms 6356 KB Output is correct
47 Correct 36 ms 6356 KB Output is correct
48 Correct 3 ms 6356 KB Output is correct
49 Correct 39 ms 6356 KB Output is correct
50 Correct 33 ms 6356 KB Output is correct
51 Correct 13 ms 6356 KB Output is correct
52 Correct 36 ms 6356 KB Output is correct
53 Correct 39 ms 6356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6356 KB Output is correct
2 Correct 0 ms 6356 KB Output is correct
3 Correct 0 ms 6356 KB Output is correct
4 Correct 0 ms 6356 KB Output is correct
5 Correct 0 ms 6356 KB Output is correct
6 Correct 0 ms 6356 KB Output is correct
7 Correct 0 ms 6356 KB Output is correct
8 Correct 0 ms 6356 KB Output is correct
9 Correct 0 ms 6356 KB Output is correct
10 Correct 0 ms 6356 KB Output is correct
11 Correct 0 ms 6356 KB Output is correct
12 Correct 0 ms 6356 KB Output is correct
13 Correct 0 ms 6356 KB Output is correct
14 Correct 0 ms 6356 KB Output is correct
15 Correct 0 ms 6356 KB Output is correct
16 Correct 0 ms 6356 KB Output is correct
17 Correct 0 ms 6356 KB Output is correct
18 Correct 0 ms 6356 KB Output is correct
19 Correct 0 ms 6356 KB Output is correct
20 Correct 0 ms 6356 KB Output is correct
21 Correct 0 ms 6356 KB Output is correct
22 Correct 0 ms 6356 KB Output is correct
23 Correct 0 ms 6356 KB Output is correct
24 Correct 0 ms 6356 KB Output is correct
25 Correct 0 ms 6356 KB Output is correct
26 Correct 0 ms 6356 KB Output is correct
27 Correct 0 ms 6356 KB Output is correct
28 Correct 0 ms 6356 KB Output is correct
29 Correct 0 ms 6356 KB Output is correct
30 Correct 0 ms 6356 KB Output is correct
31 Correct 0 ms 6356 KB Output is correct
32 Correct 0 ms 6356 KB Output is correct
33 Correct 0 ms 6356 KB Output is correct
34 Correct 0 ms 6356 KB Output is correct
35 Correct 0 ms 6356 KB Output is correct
36 Correct 0 ms 6356 KB Output is correct
37 Correct 0 ms 6356 KB Output is correct
38 Correct 0 ms 6356 KB Output is correct
39 Correct 36 ms 6356 KB Output is correct
40 Correct 39 ms 6356 KB Output is correct
41 Correct 36 ms 6356 KB Output is correct
42 Correct 36 ms 6356 KB Output is correct
43 Correct 43 ms 6356 KB Output is correct
44 Correct 46 ms 6356 KB Output is correct
45 Correct 36 ms 6356 KB Output is correct
46 Correct 26 ms 6356 KB Output is correct
47 Correct 36 ms 6356 KB Output is correct
48 Correct 3 ms 6356 KB Output is correct
49 Correct 39 ms 6356 KB Output is correct
50 Correct 33 ms 6356 KB Output is correct
51 Correct 13 ms 6356 KB Output is correct
52 Correct 36 ms 6356 KB Output is correct
53 Correct 39 ms 6356 KB Output is correct
54 Correct 39 ms 6356 KB Output is correct
55 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
56 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
57 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
58 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
59 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
60 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
61 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
62 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
63 Runtime error 33 ms 6356 KB Execution timed out (wall clock limit exceeded)
64 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
65 Incorrect 0 ms 6356 KB Unexpected end of file - int32 expected
66 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
67 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
68 Runtime error 63 ms 6356 KB Execution timed out (wall clock limit exceeded)
69 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6356 KB Output is correct
2 Correct 0 ms 6356 KB Output is correct
3 Correct 0 ms 6356 KB Output is correct
4 Correct 0 ms 6356 KB Output is correct
5 Correct 0 ms 6356 KB Output is correct
6 Correct 0 ms 6356 KB Output is correct
7 Correct 0 ms 6356 KB Output is correct
8 Correct 0 ms 6356 KB Output is correct
9 Correct 0 ms 6356 KB Output is correct
10 Correct 0 ms 6356 KB Output is correct
11 Correct 0 ms 6356 KB Output is correct
12 Correct 0 ms 6356 KB Output is correct
13 Correct 0 ms 6356 KB Output is correct
14 Correct 0 ms 6356 KB Output is correct
15 Correct 0 ms 6356 KB Output is correct
16 Correct 0 ms 6356 KB Output is correct
17 Correct 0 ms 6356 KB Output is correct
18 Correct 0 ms 6356 KB Output is correct
19 Correct 0 ms 6356 KB Output is correct
20 Correct 0 ms 6356 KB Output is correct
21 Correct 0 ms 6356 KB Output is correct
22 Correct 0 ms 6356 KB Output is correct
23 Correct 0 ms 6356 KB Output is correct
24 Correct 0 ms 6356 KB Output is correct
25 Correct 0 ms 6356 KB Output is correct
26 Correct 0 ms 6356 KB Output is correct
27 Correct 0 ms 6356 KB Output is correct
28 Correct 0 ms 6356 KB Output is correct
29 Correct 0 ms 6356 KB Output is correct
30 Correct 0 ms 6356 KB Output is correct
31 Correct 0 ms 6356 KB Output is correct
32 Correct 0 ms 6356 KB Output is correct
33 Correct 0 ms 6356 KB Output is correct
34 Correct 0 ms 6356 KB Output is correct
35 Correct 0 ms 6356 KB Output is correct
36 Correct 0 ms 6356 KB Output is correct
37 Correct 0 ms 6356 KB Output is correct
38 Correct 0 ms 6356 KB Output is correct
39 Correct 36 ms 6356 KB Output is correct
40 Correct 39 ms 6356 KB Output is correct
41 Correct 36 ms 6356 KB Output is correct
42 Correct 36 ms 6356 KB Output is correct
43 Correct 43 ms 6356 KB Output is correct
44 Correct 46 ms 6356 KB Output is correct
45 Correct 36 ms 6356 KB Output is correct
46 Correct 26 ms 6356 KB Output is correct
47 Correct 36 ms 6356 KB Output is correct
48 Correct 3 ms 6356 KB Output is correct
49 Correct 39 ms 6356 KB Output is correct
50 Correct 33 ms 6356 KB Output is correct
51 Correct 13 ms 6356 KB Output is correct
52 Correct 36 ms 6356 KB Output is correct
53 Correct 39 ms 6356 KB Output is correct
54 Correct 39 ms 6356 KB Output is correct
55 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
56 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
57 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
58 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
59 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
60 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
61 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
62 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
63 Runtime error 33 ms 6356 KB Execution timed out (wall clock limit exceeded)
64 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
65 Incorrect 0 ms 6356 KB Unexpected end of file - int32 expected
66 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
67 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
68 Runtime error 63 ms 6356 KB Execution timed out (wall clock limit exceeded)
69 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
70 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
71 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
72 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
73 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
74 Incorrect 0 ms 6356 KB Unexpected end of file - int32 expected
75 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
76 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
77 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
78 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
79 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
80 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
81 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
82 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
83 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
84 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
85 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
86 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
87 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
88 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
89 Runtime error 0 ms 6356 KB Execution killed because of forbidden syscall futex (202)
90 Incorrect 0 ms 6356 KB Unexpected end of file - int32 expected
91 Incorrect 0 ms 6356 KB Unexpected end of file - int32 expected
92 Incorrect 0 ms 6356 KB Unexpected end of file - int32 expected