답안 #78525

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
78525 2018-10-05T15:16:48 Z Origims Xylophone (JOI18_xylophone) C++14
100 / 100
101 ms 844 KB
#include <xylophone.h>

void solve (int n) {
	int a[n], d1[n], d2[n];
	for (int i = 0; i < n - 1; i++)
		d1[i] = query(i + 1, i + 2);
	for (int i = 0; i < n - 2; i++)
		d2[i] = query(i + 1, i + 3);
	a[0] = 0, a[1] = d1[0];
	bool tmp = 1;
	for (int i = 2; i < n; i++) {
		tmp = ((d1[i - 2] + d1[i - 1] != d2[i - 2]) ? !tmp : tmp);
		a[i] = a[i - 1] + (tmp ? +1 : -1) * d1[i - 1];
	}
	int mx = 0, mxi = 0, mi = 0, mii = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > mx)
			mx = a[i], mxi = i;
		if (a[i] < mi)
			mi = a[i], mii = i;
	}
	if (mii < mxi) {
		for (int i = 0; i < n; i++)
			answer(i + 1, a[i] - mi + 1);
	}
	else {
		for (int i = 0; i < n; i++)
			answer(i + 1, mx - a[i] + 1);
	}
	return ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 324 KB Output is correct
3 Correct 2 ms 324 KB Output is correct
4 Correct 3 ms 324 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 3 ms 420 KB Output is correct
7 Correct 3 ms 420 KB Output is correct
8 Correct 3 ms 496 KB Output is correct
9 Correct 3 ms 496 KB Output is correct
10 Correct 4 ms 496 KB Output is correct
11 Correct 3 ms 496 KB Output is correct
12 Correct 3 ms 496 KB Output is correct
13 Correct 3 ms 496 KB Output is correct
14 Correct 3 ms 496 KB Output is correct
15 Correct 3 ms 496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 324 KB Output is correct
3 Correct 2 ms 324 KB Output is correct
4 Correct 3 ms 324 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 3 ms 420 KB Output is correct
7 Correct 3 ms 420 KB Output is correct
8 Correct 3 ms 496 KB Output is correct
9 Correct 3 ms 496 KB Output is correct
10 Correct 4 ms 496 KB Output is correct
11 Correct 3 ms 496 KB Output is correct
12 Correct 3 ms 496 KB Output is correct
13 Correct 3 ms 496 KB Output is correct
14 Correct 3 ms 496 KB Output is correct
15 Correct 3 ms 496 KB Output is correct
16 Correct 6 ms 496 KB Output is correct
17 Correct 6 ms 516 KB Output is correct
18 Correct 18 ms 548 KB Output is correct
19 Correct 16 ms 548 KB Output is correct
20 Correct 17 ms 548 KB Output is correct
21 Correct 16 ms 548 KB Output is correct
22 Correct 17 ms 548 KB Output is correct
23 Correct 10 ms 552 KB Output is correct
24 Correct 17 ms 572 KB Output is correct
25 Correct 10 ms 680 KB Output is correct
26 Correct 18 ms 680 KB Output is correct
27 Correct 16 ms 680 KB Output is correct
28 Correct 18 ms 680 KB Output is correct
29 Correct 20 ms 680 KB Output is correct
30 Correct 17 ms 680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 324 KB Output is correct
3 Correct 2 ms 324 KB Output is correct
4 Correct 3 ms 324 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 3 ms 420 KB Output is correct
7 Correct 3 ms 420 KB Output is correct
8 Correct 3 ms 496 KB Output is correct
9 Correct 3 ms 496 KB Output is correct
10 Correct 4 ms 496 KB Output is correct
11 Correct 3 ms 496 KB Output is correct
12 Correct 3 ms 496 KB Output is correct
13 Correct 3 ms 496 KB Output is correct
14 Correct 3 ms 496 KB Output is correct
15 Correct 3 ms 496 KB Output is correct
16 Correct 6 ms 496 KB Output is correct
17 Correct 6 ms 516 KB Output is correct
18 Correct 18 ms 548 KB Output is correct
19 Correct 16 ms 548 KB Output is correct
20 Correct 17 ms 548 KB Output is correct
21 Correct 16 ms 548 KB Output is correct
22 Correct 17 ms 548 KB Output is correct
23 Correct 10 ms 552 KB Output is correct
24 Correct 17 ms 572 KB Output is correct
25 Correct 10 ms 680 KB Output is correct
26 Correct 18 ms 680 KB Output is correct
27 Correct 16 ms 680 KB Output is correct
28 Correct 18 ms 680 KB Output is correct
29 Correct 20 ms 680 KB Output is correct
30 Correct 17 ms 680 KB Output is correct
31 Correct 22 ms 680 KB Output is correct
32 Correct 42 ms 704 KB Output is correct
33 Correct 44 ms 704 KB Output is correct
34 Correct 72 ms 704 KB Output is correct
35 Correct 72 ms 704 KB Output is correct
36 Correct 41 ms 704 KB Output is correct
37 Correct 69 ms 704 KB Output is correct
38 Correct 80 ms 704 KB Output is correct
39 Correct 98 ms 704 KB Output is correct
40 Correct 46 ms 704 KB Output is correct
41 Correct 41 ms 704 KB Output is correct
42 Correct 72 ms 704 KB Output is correct
43 Correct 80 ms 716 KB Output is correct
44 Correct 72 ms 716 KB Output is correct
45 Correct 79 ms 716 KB Output is correct
46 Correct 101 ms 716 KB Output is correct
47 Correct 75 ms 716 KB Output is correct
48 Correct 46 ms 716 KB Output is correct
49 Correct 74 ms 716 KB Output is correct
50 Correct 78 ms 716 KB Output is correct
51 Correct 82 ms 716 KB Output is correct
52 Correct 48 ms 716 KB Output is correct
53 Correct 49 ms 716 KB Output is correct
54 Correct 46 ms 716 KB Output is correct
55 Correct 46 ms 716 KB Output is correct
56 Correct 68 ms 728 KB Output is correct
57 Correct 59 ms 728 KB Output is correct
58 Correct 79 ms 728 KB Output is correct
59 Correct 88 ms 728 KB Output is correct
60 Correct 73 ms 844 KB Output is correct