#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[5003],minn,maxx,idx,idx1;
void solve(int n){
a=query(1,2);
A[1]=0; A[2]=a;
minn=0; idx=1; maxx=a; idx1=2;
for(long long i=3;i<=n;i++) {
a=query(i-1,i);
b=query(i-2,i);
if(A[i-1]>A[i-2]) {
if(b==A[i-1]-A[i-2]+a) A[i]=A[i-1]+a;
else A[i]=A[i-1]-a;
}
else {
if(b==A[i-2]-A[i-1]+a) A[i]=A[i-1]-a;
else A[i]=A[i-1]+a;
}
if(minn>A[i]) { minn=A[i]; idx=i; }
if(maxx<A[i]) { maxx=A[i]; idx1=i; }
}
if(idx1<idx) {
for(long long i=1;i<=n;i++)
A[i]=-A[i];
}
minn=0;
for(long long i=1;i<=n;i++)
minn=min(minn,A[i]);
for(long long i=1;i<=n;i++) {
A[i]-=minn-1;
}
for(long long i=1;i<=n;i++) {
answer(i,A[i]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
3 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
3 ms |
256 KB |
Output is correct |
16 |
Correct |
5 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
20 ms |
256 KB |
Output is correct |
19 |
Correct |
11 ms |
376 KB |
Output is correct |
20 |
Correct |
24 ms |
256 KB |
Output is correct |
21 |
Correct |
25 ms |
376 KB |
Output is correct |
22 |
Correct |
25 ms |
256 KB |
Output is correct |
23 |
Correct |
20 ms |
256 KB |
Output is correct |
24 |
Correct |
19 ms |
376 KB |
Output is correct |
25 |
Correct |
17 ms |
376 KB |
Output is correct |
26 |
Correct |
24 ms |
376 KB |
Output is correct |
27 |
Correct |
26 ms |
384 KB |
Output is correct |
28 |
Correct |
18 ms |
384 KB |
Output is correct |
29 |
Correct |
20 ms |
384 KB |
Output is correct |
30 |
Correct |
20 ms |
496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
3 ms |
256 KB |
Output is correct |
16 |
Correct |
5 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
20 ms |
256 KB |
Output is correct |
19 |
Correct |
11 ms |
376 KB |
Output is correct |
20 |
Correct |
24 ms |
256 KB |
Output is correct |
21 |
Correct |
25 ms |
376 KB |
Output is correct |
22 |
Correct |
25 ms |
256 KB |
Output is correct |
23 |
Correct |
20 ms |
256 KB |
Output is correct |
24 |
Correct |
19 ms |
376 KB |
Output is correct |
25 |
Correct |
17 ms |
376 KB |
Output is correct |
26 |
Correct |
24 ms |
376 KB |
Output is correct |
27 |
Correct |
26 ms |
384 KB |
Output is correct |
28 |
Correct |
18 ms |
384 KB |
Output is correct |
29 |
Correct |
20 ms |
384 KB |
Output is correct |
30 |
Correct |
20 ms |
496 KB |
Output is correct |
31 |
Correct |
39 ms |
376 KB |
Output is correct |
32 |
Correct |
35 ms |
384 KB |
Output is correct |
33 |
Correct |
97 ms |
496 KB |
Output is correct |
34 |
Correct |
88 ms |
504 KB |
Output is correct |
35 |
Correct |
134 ms |
376 KB |
Output is correct |
36 |
Correct |
105 ms |
516 KB |
Output is correct |
37 |
Correct |
83 ms |
376 KB |
Output is correct |
38 |
Correct |
90 ms |
504 KB |
Output is correct |
39 |
Correct |
95 ms |
512 KB |
Output is correct |
40 |
Correct |
126 ms |
376 KB |
Output is correct |
41 |
Correct |
114 ms |
376 KB |
Output is correct |
42 |
Correct |
136 ms |
368 KB |
Output is correct |
43 |
Correct |
93 ms |
376 KB |
Output is correct |
44 |
Correct |
80 ms |
376 KB |
Output is correct |
45 |
Correct |
83 ms |
376 KB |
Output is correct |
46 |
Correct |
95 ms |
504 KB |
Output is correct |
47 |
Correct |
92 ms |
376 KB |
Output is correct |
48 |
Correct |
51 ms |
376 KB |
Output is correct |
49 |
Correct |
103 ms |
392 KB |
Output is correct |
50 |
Correct |
74 ms |
504 KB |
Output is correct |
51 |
Correct |
118 ms |
504 KB |
Output is correct |
52 |
Correct |
93 ms |
376 KB |
Output is correct |
53 |
Correct |
61 ms |
504 KB |
Output is correct |
54 |
Correct |
90 ms |
376 KB |
Output is correct |
55 |
Correct |
96 ms |
376 KB |
Output is correct |
56 |
Correct |
90 ms |
380 KB |
Output is correct |
57 |
Correct |
68 ms |
524 KB |
Output is correct |
58 |
Correct |
114 ms |
508 KB |
Output is correct |
59 |
Correct |
93 ms |
384 KB |
Output is correct |
60 |
Correct |
118 ms |
408 KB |
Output is correct |