#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
#define name "aaaaaa"
using ll = long long;
using pii = pair<ll, ll>;
void file(){
}
const int maxn = 1e4 + 5;
ll a[maxn], type[maxn], out[maxn];
void solve (int n){
a[2] = query(1, 2);
type[2] = 0;
ll last = a[2];
for(int i = 3; i <= n; i++){
ll q = query(i - 1, i), sus = query(i - 2, i);
a[i] = q;
if(last + q == sus){
type[i] = type[i - 1];
}else{
type[i] = !type[i - 1];
}
last = q;
}
for(int i = 1; i <= n; i++){
out[i] = out[i - 1] + a[i] * (-type[i] * 2 + 1);
}
int maxpos = 1, minpos = 1;
for(int i = 2; i <= n; i++){
if(out[maxpos] < out[i]){
maxpos = i;
}
if(out[minpos] > out[i]){
minpos = i;
}
}
if(maxpos < minpos){
for(int i = 1; i <= n; i++){
type[i] = !type[i];
out[i] = out[i - 1] + a[i] * (-type[i] * 2 + 1);
}
}
ll in = 1e18;
for(int i = 1; i <= n; i++){
in = min(in, out[i]);
}
for(int i = 1; i <= n; i++){
out[i] = out[i] - in + 1;
}
for(int i = 1; i <= n; i++){
answer(i, out[i]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 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 |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 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 |
344 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 |
344 KB |
Output is correct |
18 |
Correct |
8 ms |
468 KB |
Output is correct |
19 |
Correct |
9 ms |
476 KB |
Output is correct |
20 |
Correct |
10 ms |
600 KB |
Output is correct |
21 |
Correct |
13 ms |
344 KB |
Output is correct |
22 |
Correct |
9 ms |
344 KB |
Output is correct |
23 |
Correct |
10 ms |
344 KB |
Output is correct |
24 |
Correct |
9 ms |
344 KB |
Output is correct |
25 |
Correct |
9 ms |
344 KB |
Output is correct |
26 |
Correct |
9 ms |
460 KB |
Output is correct |
27 |
Correct |
13 ms |
476 KB |
Output is correct |
28 |
Correct |
10 ms |
720 KB |
Output is correct |
29 |
Correct |
9 ms |
464 KB |
Output is correct |
30 |
Correct |
8 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 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 |
344 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 |
344 KB |
Output is correct |
18 |
Correct |
8 ms |
468 KB |
Output is correct |
19 |
Correct |
9 ms |
476 KB |
Output is correct |
20 |
Correct |
10 ms |
600 KB |
Output is correct |
21 |
Correct |
13 ms |
344 KB |
Output is correct |
22 |
Correct |
9 ms |
344 KB |
Output is correct |
23 |
Correct |
10 ms |
344 KB |
Output is correct |
24 |
Correct |
9 ms |
344 KB |
Output is correct |
25 |
Correct |
9 ms |
344 KB |
Output is correct |
26 |
Correct |
9 ms |
460 KB |
Output is correct |
27 |
Correct |
13 ms |
476 KB |
Output is correct |
28 |
Correct |
10 ms |
720 KB |
Output is correct |
29 |
Correct |
9 ms |
464 KB |
Output is correct |
30 |
Correct |
8 ms |
344 KB |
Output is correct |
31 |
Correct |
19 ms |
344 KB |
Output is correct |
32 |
Correct |
39 ms |
704 KB |
Output is correct |
33 |
Correct |
38 ms |
704 KB |
Output is correct |
34 |
Correct |
48 ms |
740 KB |
Output is correct |
35 |
Correct |
68 ms |
712 KB |
Output is correct |
36 |
Correct |
55 ms |
592 KB |
Output is correct |
37 |
Correct |
65 ms |
472 KB |
Output is correct |
38 |
Correct |
54 ms |
344 KB |
Output is correct |
39 |
Correct |
48 ms |
848 KB |
Output is correct |
40 |
Correct |
44 ms |
728 KB |
Output is correct |
41 |
Correct |
55 ms |
592 KB |
Output is correct |
42 |
Correct |
61 ms |
344 KB |
Output is correct |
43 |
Correct |
58 ms |
600 KB |
Output is correct |
44 |
Correct |
58 ms |
688 KB |
Output is correct |
45 |
Correct |
45 ms |
468 KB |
Output is correct |
46 |
Correct |
56 ms |
472 KB |
Output is correct |
47 |
Correct |
54 ms |
496 KB |
Output is correct |
48 |
Correct |
49 ms |
736 KB |
Output is correct |
49 |
Correct |
51 ms |
752 KB |
Output is correct |
50 |
Correct |
49 ms |
616 KB |
Output is correct |
51 |
Correct |
74 ms |
960 KB |
Output is correct |
52 |
Correct |
54 ms |
592 KB |
Output is correct |
53 |
Correct |
49 ms |
960 KB |
Output is correct |
54 |
Correct |
59 ms |
496 KB |
Output is correct |
55 |
Correct |
50 ms |
484 KB |
Output is correct |
56 |
Correct |
61 ms |
712 KB |
Output is correct |
57 |
Correct |
46 ms |
748 KB |
Output is correct |
58 |
Correct |
69 ms |
872 KB |
Output is correct |
59 |
Correct |
63 ms |
1104 KB |
Output is correct |
60 |
Correct |
51 ms |
604 KB |
Output is correct |