#include <bits/stdc++.h>
#include "xylophone.h"
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))
using namespace std;
const ll LINF = 4e18;
const int mxN = 1e6+10, INF = 2e9;
ll n, m, a[mxN], b[2][mxN];
void solve(int N){
for (int i = 2; i <= N; i++) b[0][i] = query(i-1, i);
for (int i = 3; i <= N; i++) b[1][i] = query(i-2, i);
a[1] = 0; a[2] = b[0][2];
for (int i = 3; i <= N; i++){
int t1 = (b[0][i-1] + b[0][i] == b[1][i] ? 1 : -1);
int t2 = (a[i-1] > a[i-2] ? 1 : -1);
a[i] = a[i-1] + t1*t2*b[0][i];
}
array<int, 2> idx = {1, 1};
for (int i = 2; i <= N; i++){
if (a[i] < a[idx[0]]) idx[0] = i;
if (a[i] > a[idx[1]]) idx[1] = i;
}
if (idx[0] > idx[1]){
for (int i = 1; i <= N; i++)
a[i] *= -1;
swap(idx[0], idx[1]);
}
int d = 1-a[idx[0]];
for (int i = 1; i <= N; i++)
answer(i, a[i]+d);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
312 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
208 KB |
Output is correct |
9 |
Correct |
2 ms |
208 KB |
Output is correct |
10 |
Correct |
3 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
2 ms |
208 KB |
Output is correct |
13 |
Correct |
2 ms |
308 KB |
Output is correct |
14 |
Correct |
2 ms |
208 KB |
Output is correct |
15 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
312 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
208 KB |
Output is correct |
9 |
Correct |
2 ms |
208 KB |
Output is correct |
10 |
Correct |
3 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
2 ms |
208 KB |
Output is correct |
13 |
Correct |
2 ms |
308 KB |
Output is correct |
14 |
Correct |
2 ms |
208 KB |
Output is correct |
15 |
Correct |
2 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
316 KB |
Output is correct |
17 |
Correct |
8 ms |
208 KB |
Output is correct |
18 |
Correct |
13 ms |
328 KB |
Output is correct |
19 |
Correct |
16 ms |
312 KB |
Output is correct |
20 |
Correct |
14 ms |
336 KB |
Output is correct |
21 |
Correct |
14 ms |
320 KB |
Output is correct |
22 |
Correct |
15 ms |
308 KB |
Output is correct |
23 |
Correct |
14 ms |
328 KB |
Output is correct |
24 |
Correct |
13 ms |
332 KB |
Output is correct |
25 |
Correct |
13 ms |
324 KB |
Output is correct |
26 |
Correct |
15 ms |
304 KB |
Output is correct |
27 |
Correct |
15 ms |
328 KB |
Output is correct |
28 |
Correct |
16 ms |
316 KB |
Output is correct |
29 |
Correct |
13 ms |
436 KB |
Output is correct |
30 |
Correct |
15 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
312 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
208 KB |
Output is correct |
9 |
Correct |
2 ms |
208 KB |
Output is correct |
10 |
Correct |
3 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
208 KB |
Output is correct |
12 |
Correct |
2 ms |
208 KB |
Output is correct |
13 |
Correct |
2 ms |
308 KB |
Output is correct |
14 |
Correct |
2 ms |
208 KB |
Output is correct |
15 |
Correct |
2 ms |
208 KB |
Output is correct |
16 |
Correct |
5 ms |
316 KB |
Output is correct |
17 |
Correct |
8 ms |
208 KB |
Output is correct |
18 |
Correct |
13 ms |
328 KB |
Output is correct |
19 |
Correct |
16 ms |
312 KB |
Output is correct |
20 |
Correct |
14 ms |
336 KB |
Output is correct |
21 |
Correct |
14 ms |
320 KB |
Output is correct |
22 |
Correct |
15 ms |
308 KB |
Output is correct |
23 |
Correct |
14 ms |
328 KB |
Output is correct |
24 |
Correct |
13 ms |
332 KB |
Output is correct |
25 |
Correct |
13 ms |
324 KB |
Output is correct |
26 |
Correct |
15 ms |
304 KB |
Output is correct |
27 |
Correct |
15 ms |
328 KB |
Output is correct |
28 |
Correct |
16 ms |
316 KB |
Output is correct |
29 |
Correct |
13 ms |
436 KB |
Output is correct |
30 |
Correct |
15 ms |
328 KB |
Output is correct |
31 |
Correct |
32 ms |
448 KB |
Output is correct |
32 |
Correct |
51 ms |
344 KB |
Output is correct |
33 |
Correct |
62 ms |
556 KB |
Output is correct |
34 |
Correct |
51 ms |
460 KB |
Output is correct |
35 |
Correct |
66 ms |
444 KB |
Output is correct |
36 |
Correct |
96 ms |
432 KB |
Output is correct |
37 |
Correct |
64 ms |
588 KB |
Output is correct |
38 |
Correct |
55 ms |
368 KB |
Output is correct |
39 |
Correct |
83 ms |
428 KB |
Output is correct |
40 |
Correct |
94 ms |
436 KB |
Output is correct |
41 |
Correct |
79 ms |
456 KB |
Output is correct |
42 |
Correct |
89 ms |
420 KB |
Output is correct |
43 |
Correct |
77 ms |
444 KB |
Output is correct |
44 |
Correct |
73 ms |
448 KB |
Output is correct |
45 |
Correct |
77 ms |
376 KB |
Output is correct |
46 |
Correct |
54 ms |
576 KB |
Output is correct |
47 |
Correct |
87 ms |
344 KB |
Output is correct |
48 |
Correct |
67 ms |
444 KB |
Output is correct |
49 |
Correct |
87 ms |
576 KB |
Output is correct |
50 |
Correct |
88 ms |
428 KB |
Output is correct |
51 |
Correct |
77 ms |
344 KB |
Output is correct |
52 |
Correct |
83 ms |
436 KB |
Output is correct |
53 |
Correct |
78 ms |
444 KB |
Output is correct |
54 |
Correct |
84 ms |
372 KB |
Output is correct |
55 |
Correct |
83 ms |
584 KB |
Output is correct |
56 |
Correct |
68 ms |
448 KB |
Output is correct |
57 |
Correct |
88 ms |
456 KB |
Output is correct |
58 |
Correct |
87 ms |
500 KB |
Output is correct |
59 |
Correct |
93 ms |
456 KB |
Output is correct |
60 |
Correct |
92 ms |
556 KB |
Output is correct |