#include "xylophone.h"
static int a[5000],b[5000];
int c[5000],d[5000];
void solve(int N) {
int n=N;
for(int i=0;i<n-1;i++){
c[i]=query(i+1,i+2);
}
for(int i=0;i<n-2;i++){
d[i]=query(i+1,i+3);
}
b[0]=c[0];
for(int i=0;i<n-2;i++){
if(d[i]==c[i]+c[i+1]){
if(b[i]>0) b[i+1]=c[i+1];
else b[i+1]=-c[i+1];
}
else{
if(b[i]>0) b[i+1]=-c[i+1];
else b[i+1]=c[i+1];
}
}
for(int i=0;i<n-1;i++){
a[i+1]=a[i]+b[i];
}
int mn=0,mx=0;
for(int i=0;i<n;i++){
if(a[mn]>a[i]) mn=i;
if(a[mx]<a[i]) mx=i;
}
if(mn>mx){
for(int i=0;i<n-1;i++){
a[i+1]=a[i]-b[i];
}
}
mn=0;
for(int i=0;i<n;i++) if(mn>a[i]) mn=a[i];
for(int i=0;i<n;i++) a[i]+=(1-mn);
for(int i=0;i<n;i++) answer(i+1,a[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
364 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
3 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
3 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
3 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
364 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
3 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
3 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
3 ms |
364 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
12 ms |
364 KB |
Output is correct |
18 |
Correct |
14 ms |
364 KB |
Output is correct |
19 |
Correct |
26 ms |
364 KB |
Output is correct |
20 |
Correct |
22 ms |
500 KB |
Output is correct |
21 |
Correct |
30 ms |
364 KB |
Output is correct |
22 |
Correct |
34 ms |
364 KB |
Output is correct |
23 |
Correct |
26 ms |
364 KB |
Output is correct |
24 |
Correct |
18 ms |
364 KB |
Output is correct |
25 |
Correct |
19 ms |
492 KB |
Output is correct |
26 |
Correct |
16 ms |
492 KB |
Output is correct |
27 |
Correct |
25 ms |
372 KB |
Output is correct |
28 |
Correct |
16 ms |
364 KB |
Output is correct |
29 |
Correct |
24 ms |
364 KB |
Output is correct |
30 |
Correct |
21 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
2 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
364 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
3 ms |
364 KB |
Output is correct |
12 |
Correct |
2 ms |
364 KB |
Output is correct |
13 |
Correct |
3 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
3 ms |
364 KB |
Output is correct |
16 |
Correct |
6 ms |
384 KB |
Output is correct |
17 |
Correct |
12 ms |
364 KB |
Output is correct |
18 |
Correct |
14 ms |
364 KB |
Output is correct |
19 |
Correct |
26 ms |
364 KB |
Output is correct |
20 |
Correct |
22 ms |
500 KB |
Output is correct |
21 |
Correct |
30 ms |
364 KB |
Output is correct |
22 |
Correct |
34 ms |
364 KB |
Output is correct |
23 |
Correct |
26 ms |
364 KB |
Output is correct |
24 |
Correct |
18 ms |
364 KB |
Output is correct |
25 |
Correct |
19 ms |
492 KB |
Output is correct |
26 |
Correct |
16 ms |
492 KB |
Output is correct |
27 |
Correct |
25 ms |
372 KB |
Output is correct |
28 |
Correct |
16 ms |
364 KB |
Output is correct |
29 |
Correct |
24 ms |
364 KB |
Output is correct |
30 |
Correct |
21 ms |
364 KB |
Output is correct |
31 |
Correct |
56 ms |
364 KB |
Output is correct |
32 |
Correct |
50 ms |
364 KB |
Output is correct |
33 |
Correct |
79 ms |
364 KB |
Output is correct |
34 |
Correct |
83 ms |
364 KB |
Output is correct |
35 |
Correct |
126 ms |
364 KB |
Output is correct |
36 |
Correct |
114 ms |
492 KB |
Output is correct |
37 |
Correct |
55 ms |
368 KB |
Output is correct |
38 |
Correct |
97 ms |
364 KB |
Output is correct |
39 |
Correct |
116 ms |
492 KB |
Output is correct |
40 |
Correct |
90 ms |
364 KB |
Output is correct |
41 |
Correct |
87 ms |
364 KB |
Output is correct |
42 |
Correct |
94 ms |
492 KB |
Output is correct |
43 |
Correct |
78 ms |
364 KB |
Output is correct |
44 |
Correct |
105 ms |
364 KB |
Output is correct |
45 |
Correct |
89 ms |
364 KB |
Output is correct |
46 |
Correct |
123 ms |
492 KB |
Output is correct |
47 |
Correct |
86 ms |
364 KB |
Output is correct |
48 |
Correct |
93 ms |
516 KB |
Output is correct |
49 |
Correct |
87 ms |
492 KB |
Output is correct |
50 |
Correct |
109 ms |
492 KB |
Output is correct |
51 |
Correct |
115 ms |
624 KB |
Output is correct |
52 |
Correct |
107 ms |
492 KB |
Output is correct |
53 |
Correct |
80 ms |
492 KB |
Output is correct |
54 |
Correct |
92 ms |
364 KB |
Output is correct |
55 |
Correct |
85 ms |
364 KB |
Output is correct |
56 |
Correct |
92 ms |
620 KB |
Output is correct |
57 |
Correct |
121 ms |
492 KB |
Output is correct |
58 |
Correct |
86 ms |
492 KB |
Output is correct |
59 |
Correct |
88 ms |
496 KB |
Output is correct |
60 |
Correct |
83 ms |
624 KB |
Output is correct |