# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
981352 | 2024-05-13T05:19:42 Z | Amaarsaa | Xylophone (JOI18_xylophone) | C++14 | 54 ms | 1260 KB |
#include<bits/stdc++.h> #include "xylophone.h" using namespace std; int a[5002], ans[5002]; void solve(int N) { int ind, mid,i, s,x1, x2, p, n = N, lo, hi; int r, b[5005], c[5005], ens[5005]; ans[1] = 0; ans[2] = 0 + query(1, 2); r = ans[2]; int mx = ans[2]; for ( i = 3; i <= n; i ++) { s = query(i - 1, i); p = query(i - 2, i); b[i]= s; c[i] = p; x1 = ans[i - 1] - s; x2 = ans[i - 1] + s; if ( max(x1, max(ans[i - 1], ans[i - 2])) - min(x1, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x1; } if ( max(x2, max(ans[i - 1], ans[i - 2])) - min(x2, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x2; } mx = max(mx,ans[i]); } int j = 1, J = 1; for (i = 1; i <= n; i ++) { ens[i] = ans[i]= ans[i] + (n - mx); if ( ans[i] == n) j = i; if ( ans[i] == 1) J = i; } sort ( ens + 1, ens + n + 1); int can = 1; for (i =1; i <= n; i ++) if ( ens[i] != i) can = 0; if ( can && J < j) { // for (i = 1; i <= n; i ++) cout << ans[i] << " "; for (i = 1; i <= n; i ++) answer(i, ans[i]); return ; } ans[1] = 0; ans[2] = -r; mx = 0; for ( i = 3; i <= n; i ++) { s = b[i]; p = c[i]; x1 = ans[i - 1] - s; x2 = ans[i - 1] + s; if ( max(x1, max(ans[i - 1], ans[i - 2])) - min(x1, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x1; } if ( max(x2, max(ans[i - 1], ans[i - 2])) - min(x2, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x2; } mx = max(mx,ans[i]); } for (i = 1; i <= n; i ++) ans[i] = ans[i] + (n - mx); // for (i = 1; i <= n; i ++) cout << ans[i] << " "; for (i =1 ; i<= n; i++) answer(i, ans[i]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 2 ms | 344 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 356 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 2 ms | 344 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 356 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
16 | Correct | 2 ms | 344 KB | Output is correct |
17 | Correct | 4 ms | 504 KB | Output is correct |
18 | Correct | 9 ms | 496 KB | Output is correct |
19 | Correct | 7 ms | 752 KB | Output is correct |
20 | Correct | 10 ms | 752 KB | Output is correct |
21 | Correct | 9 ms | 756 KB | Output is correct |
22 | Correct | 7 ms | 496 KB | Output is correct |
23 | Correct | 7 ms | 756 KB | Output is correct |
24 | Correct | 7 ms | 492 KB | Output is correct |
25 | Correct | 10 ms | 760 KB | Output is correct |
26 | Correct | 9 ms | 748 KB | Output is correct |
27 | Correct | 10 ms | 500 KB | Output is correct |
28 | Correct | 8 ms | 748 KB | Output is correct |
29 | Correct | 8 ms | 504 KB | Output is correct |
30 | Correct | 8 ms | 752 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 2 ms | 344 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 356 KB | Output is correct |
15 | Correct | 1 ms | 344 KB | Output is correct |
16 | Correct | 2 ms | 344 KB | Output is correct |
17 | Correct | 4 ms | 504 KB | Output is correct |
18 | Correct | 9 ms | 496 KB | Output is correct |
19 | Correct | 7 ms | 752 KB | Output is correct |
20 | Correct | 10 ms | 752 KB | Output is correct |
21 | Correct | 9 ms | 756 KB | Output is correct |
22 | Correct | 7 ms | 496 KB | Output is correct |
23 | Correct | 7 ms | 756 KB | Output is correct |
24 | Correct | 7 ms | 492 KB | Output is correct |
25 | Correct | 10 ms | 760 KB | Output is correct |
26 | Correct | 9 ms | 748 KB | Output is correct |
27 | Correct | 10 ms | 500 KB | Output is correct |
28 | Correct | 8 ms | 748 KB | Output is correct |
29 | Correct | 8 ms | 504 KB | Output is correct |
30 | Correct | 8 ms | 752 KB | Output is correct |
31 | Correct | 19 ms | 752 KB | Output is correct |
32 | Correct | 28 ms | 736 KB | Output is correct |
33 | Correct | 46 ms | 496 KB | Output is correct |
34 | Correct | 50 ms | 1252 KB | Output is correct |
35 | Correct | 47 ms | 984 KB | Output is correct |
36 | Correct | 43 ms | 752 KB | Output is correct |
37 | Correct | 41 ms | 1008 KB | Output is correct |
38 | Correct | 46 ms | 752 KB | Output is correct |
39 | Correct | 51 ms | 500 KB | Output is correct |
40 | Correct | 48 ms | 748 KB | Output is correct |
41 | Correct | 43 ms | 992 KB | Output is correct |
42 | Correct | 44 ms | 740 KB | Output is correct |
43 | Correct | 54 ms | 1260 KB | Output is correct |
44 | Correct | 47 ms | 740 KB | Output is correct |
45 | Correct | 53 ms | 1000 KB | Output is correct |
46 | Correct | 54 ms | 1248 KB | Output is correct |
47 | Correct | 46 ms | 752 KB | Output is correct |
48 | Correct | 47 ms | 752 KB | Output is correct |
49 | Correct | 48 ms | 996 KB | Output is correct |
50 | Correct | 49 ms | 1252 KB | Output is correct |
51 | Correct | 40 ms | 752 KB | Output is correct |
52 | Correct | 40 ms | 780 KB | Output is correct |
53 | Correct | 47 ms | 756 KB | Output is correct |
54 | Correct | 49 ms | 992 KB | Output is correct |
55 | Correct | 47 ms | 996 KB | Output is correct |
56 | Correct | 50 ms | 992 KB | Output is correct |
57 | Correct | 54 ms | 756 KB | Output is correct |
58 | Correct | 40 ms | 996 KB | Output is correct |
59 | Correct | 47 ms | 744 KB | Output is correct |
60 | Correct | 43 ms | 1016 KB | Output is correct |