#include "xylophone.h"
#include<iostream>
using namespace std;
static int A[5000];
int max(int a, int b){
if(a>b)return a;
return b;
}
void solve(int N) {
int n=N;
//cout<<n<<endl;
int resposta1[n-1];
int resposta2[n-2];
for(int i=0;i<n-1;i++){
resposta1[i]=query(i+1,i+2);
//cout<<resposta1[i]<<endl;
}
for(int i=0;i<n-2;i++){
resposta2[i]=query(i+1,i+3);
//cout<<resposta2[i]<<endl;
}
int sign[n-1];
sign[0]=1;
for(int i=0;i<n-2;i++){
if(resposta2[i]==max(resposta1[i],resposta1[i+1])){
sign[i+1]=-sign[i];
}else{
sign[i+1]=sign[i];
}
//cout<<sign[i+1]<<endl;
}
int arr[n];
arr[0]=0;
for(int i=0;i<n-1;i++){
arr[i+1]=resposta1[i]*sign[i]+arr[i];
}
int minimo=0;
for(int i=0;i<n;i++){
if(arr[minimo]>arr[i])minimo=i;
//cout<<arr[i]<<endl;
}int minimo2=arr[minimo];
for(int i=0;i<n;i++){//cout<<arr[i]<<" ";
arr[i]+=1-minimo2;
//cout<<arr[i]<<endl;
}
int maximo=0;
for(int i=0;i<n;i++){
if(arr[maximo]<arr[i])maximo=i;
}//cout<<maximo<<endl;
if(maximo<minimo){
for(int i=0;i<n;i++)arr[i]=n-arr[i]+1;
}
for(int i=0;i<n;i++)answer(i+1,arr[i]);
}
Compilation message
xylophone.cpp:5:12: warning: 'A' defined but not used [-Wunused-variable]
static int A[5000];
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
308 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
440 KB |
Output is correct |
5 |
Correct |
5 ms |
464 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
5 ms |
464 KB |
Output is correct |
8 |
Correct |
3 ms |
464 KB |
Output is correct |
9 |
Correct |
7 ms |
500 KB |
Output is correct |
10 |
Correct |
5 ms |
500 KB |
Output is correct |
11 |
Correct |
5 ms |
500 KB |
Output is correct |
12 |
Correct |
4 ms |
500 KB |
Output is correct |
13 |
Correct |
3 ms |
500 KB |
Output is correct |
14 |
Correct |
5 ms |
500 KB |
Output is correct |
15 |
Correct |
5 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
308 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
440 KB |
Output is correct |
5 |
Correct |
5 ms |
464 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
5 ms |
464 KB |
Output is correct |
8 |
Correct |
3 ms |
464 KB |
Output is correct |
9 |
Correct |
7 ms |
500 KB |
Output is correct |
10 |
Correct |
5 ms |
500 KB |
Output is correct |
11 |
Correct |
5 ms |
500 KB |
Output is correct |
12 |
Correct |
4 ms |
500 KB |
Output is correct |
13 |
Correct |
3 ms |
500 KB |
Output is correct |
14 |
Correct |
5 ms |
500 KB |
Output is correct |
15 |
Correct |
5 ms |
500 KB |
Output is correct |
16 |
Correct |
12 ms |
500 KB |
Output is correct |
17 |
Correct |
14 ms |
500 KB |
Output is correct |
18 |
Correct |
27 ms |
528 KB |
Output is correct |
19 |
Correct |
17 ms |
528 KB |
Output is correct |
20 |
Correct |
11 ms |
564 KB |
Output is correct |
21 |
Correct |
26 ms |
572 KB |
Output is correct |
22 |
Correct |
26 ms |
572 KB |
Output is correct |
23 |
Correct |
19 ms |
572 KB |
Output is correct |
24 |
Correct |
18 ms |
572 KB |
Output is correct |
25 |
Correct |
17 ms |
572 KB |
Output is correct |
26 |
Correct |
19 ms |
572 KB |
Output is correct |
27 |
Correct |
12 ms |
572 KB |
Output is correct |
28 |
Correct |
19 ms |
572 KB |
Output is correct |
29 |
Correct |
16 ms |
572 KB |
Output is correct |
30 |
Correct |
18 ms |
572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
308 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
440 KB |
Output is correct |
5 |
Correct |
5 ms |
464 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
5 ms |
464 KB |
Output is correct |
8 |
Correct |
3 ms |
464 KB |
Output is correct |
9 |
Correct |
7 ms |
500 KB |
Output is correct |
10 |
Correct |
5 ms |
500 KB |
Output is correct |
11 |
Correct |
5 ms |
500 KB |
Output is correct |
12 |
Correct |
4 ms |
500 KB |
Output is correct |
13 |
Correct |
3 ms |
500 KB |
Output is correct |
14 |
Correct |
5 ms |
500 KB |
Output is correct |
15 |
Correct |
5 ms |
500 KB |
Output is correct |
16 |
Correct |
12 ms |
500 KB |
Output is correct |
17 |
Correct |
14 ms |
500 KB |
Output is correct |
18 |
Correct |
27 ms |
528 KB |
Output is correct |
19 |
Correct |
17 ms |
528 KB |
Output is correct |
20 |
Correct |
11 ms |
564 KB |
Output is correct |
21 |
Correct |
26 ms |
572 KB |
Output is correct |
22 |
Correct |
26 ms |
572 KB |
Output is correct |
23 |
Correct |
19 ms |
572 KB |
Output is correct |
24 |
Correct |
18 ms |
572 KB |
Output is correct |
25 |
Correct |
17 ms |
572 KB |
Output is correct |
26 |
Correct |
19 ms |
572 KB |
Output is correct |
27 |
Correct |
12 ms |
572 KB |
Output is correct |
28 |
Correct |
19 ms |
572 KB |
Output is correct |
29 |
Correct |
16 ms |
572 KB |
Output is correct |
30 |
Correct |
18 ms |
572 KB |
Output is correct |
31 |
Correct |
40 ms |
572 KB |
Output is correct |
32 |
Correct |
33 ms |
576 KB |
Output is correct |
33 |
Correct |
36 ms |
576 KB |
Output is correct |
34 |
Correct |
139 ms |
576 KB |
Output is correct |
35 |
Correct |
115 ms |
700 KB |
Output is correct |
36 |
Correct |
93 ms |
700 KB |
Output is correct |
37 |
Correct |
64 ms |
700 KB |
Output is correct |
38 |
Correct |
66 ms |
700 KB |
Output is correct |
39 |
Correct |
95 ms |
832 KB |
Output is correct |
40 |
Correct |
126 ms |
832 KB |
Output is correct |
41 |
Correct |
99 ms |
832 KB |
Output is correct |
42 |
Correct |
132 ms |
832 KB |
Output is correct |
43 |
Correct |
115 ms |
832 KB |
Output is correct |
44 |
Correct |
154 ms |
832 KB |
Output is correct |
45 |
Correct |
149 ms |
832 KB |
Output is correct |
46 |
Correct |
133 ms |
832 KB |
Output is correct |
47 |
Correct |
133 ms |
832 KB |
Output is correct |
48 |
Correct |
134 ms |
832 KB |
Output is correct |
49 |
Correct |
84 ms |
832 KB |
Output is correct |
50 |
Correct |
92 ms |
832 KB |
Output is correct |
51 |
Correct |
131 ms |
832 KB |
Output is correct |
52 |
Correct |
62 ms |
832 KB |
Output is correct |
53 |
Correct |
51 ms |
832 KB |
Output is correct |
54 |
Correct |
156 ms |
832 KB |
Output is correct |
55 |
Correct |
70 ms |
832 KB |
Output is correct |
56 |
Correct |
68 ms |
832 KB |
Output is correct |
57 |
Correct |
113 ms |
832 KB |
Output is correct |
58 |
Correct |
98 ms |
832 KB |
Output is correct |
59 |
Correct |
98 ms |
832 KB |
Output is correct |
60 |
Correct |
63 ms |
832 KB |
Output is correct |