This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "xylophone.h"
#include<bits/stdc++.h>
void solve(int N){
int mni=0, mxi=0, a[N];
a[0]=0;
a[1]=query(1, 2);
for(int i=2; i<N; i++){
a[i]=abs(query(i, i+1))+a[i-1];
if(a[i-2]<a[i-1]){
if(query(i-1, i+1)!=abs(a[i]-a[i-2])){
a[i]-=a[i-1];
a[i]*=-1;
a[i]+=a[i-1];
}
}else{
if(query(i-1, i+1)==a[i]-a[i-1]+a[i-2]-a[i-1]){
a[i]-=a[i-1];
a[i]*=-1;
a[i]+=a[i-1];
}
}
}
for(int i=0; i<N; i++){
if(a[i]<a[mni]){
mni=i;
}
if(a[i]>a[mxi]){
mxi=i;
}
}
if(mni>mxi){
mni=-1;
}else{
mni=1;
}
for(int i=0; i<N; i++){
a[i]=a[i]*mni;
if(mxi>a[i]){
mxi=a[i];
}
}
for(int i=0; i<N; i++){
answer(i+1, a[i]-mxi+1);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |