#include "xylophone.h"
#include <bits/stdc++.h>
#define inf 987654321
using namespace std;
typedef long long LL;
int arr[5010];
int dp[5010];
int ans[5010];
void solve(int n) {
for(int i=2; i<=n; i++) {
arr[i]=query(i-1, i);
}
dp[2]=1;
for(int i=3; i<=n; i++) {
int temp=query(i-2, i);
if(temp!=arr[i-1]+arr[i])
dp[i]=-dp[i-1];
else
dp[i]=dp[i-1];
}
int minnum=1, minmin=0, maxnum=1, maxmax=0;
for(int i=2; i<=n; i++) {
arr[i]*=dp[i];
ans[i]+=arr[i];
if(maxmax<ans[i]) {
maxmax=ans[i];
maxnum=i;
}
if(minmin>ans[i]) {
minmin=ans[i];
minnum=i;
}
}
if(minnum>maxnum) {
minnum=1, minmin=0, maxnum=1, maxmax=0;
for(int i=2; i<=n; i++) {
arr[i]*=-1;
ans[i]+=arr[i];
if(maxmax<ans[i]) {
maxmax=ans[i];
maxnum=i;
}
if(minmin>ans[i]) {
minmin=ans[i];
minnum=i;
}
}
}
for(int i=1; i<=n; i++){
answer(i, ans[i]-minnum+1);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
312 KB |
Wrong Answer [4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
312 KB |
Wrong Answer [4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
312 KB |
Wrong Answer [4 |
2 |
Halted |
0 ms |
0 KB |
- |