#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+10;
int dp2[maxn],dp3[maxn],n,val[maxn],vas[maxn],all[maxn];
void solve(int N) {
n=N;
//cout<<"wtf"<<n<<endl;
for(int i=2;i<=n;i++){
dp2[i]=query(i-1,i);
}
for(int i=3;i<=n;i++){
dp3[i]=query(i-2,i);
}
val[2]=dp2[2];
vas[2]=1;
for(int i=3;i<=n;i++){
if(dp3[i]==dp2[i-1]){
vas[i]=-vas[i-1];
val[i]=dp2[i];
continue;
}
if(dp3[i]==dp2[i]){
vas[i]=-vas[i-1];
val[i]=dp2[i];
continue;
}
vas[i]=vas[i-1];
val[i]=dp2[i];
}
pair<int,int>mina,maxa;
mina=make_pair(n+2,0);
maxa=make_pair(-n-2,0);
for(int i=2;i<=n;i++){
all[i]=all[i-1]+val[i]*vas[i];
mina=min(mina,make_pair(all[i],i));
maxa=max(maxa,make_pair(all[i],i));
}
if(mina.second>maxa.second){
int tof=0;
for(int i=2;i<=n;i++){
vas[i]=-vas[i];
all[i]=all[i-1]+val[i]*vas[i];
tof=min(tof,all[i]);
}
for(int i=1;i<=n;i++){
all[i]+=-tof+1;
// cout<<i<<" "<<all[i]<<" "<<tof<<endl;
answer(i,all[i]);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
436 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |