답안 #1018097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018097 2024-07-09T14:14:59 Z tigar Xylophone (JOI18_xylophone) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>
#include "xylophone.h"

using namespace std;

int ans1[5050], ans2[5050];
int mn2=0, mnp2=1, mn1=0, mnp1=1, mx1=0, mxp1=1, mx2=0, mxp2=1;

void solve(int N)
{
    ans1[1]=0; ans2[1]=0;
    ans1[2]=query(1, 2);
    ans2[2]=-query(1, 2);
    int hlast=ans1[2];
    for(int i=3; i<=N; i++)
    {
        int h1=query(i-1, i), h2=query(i-2, i);
        if(hlast+h1==h2)
        {
            if(ans1[i-1]>ans1[i-2])ans1[i]=h1+ans1[i-1];
            else ans1[i]=ans1[i-1]-h1;
            if(ans2[i-1]>ans2[i-2])ans2[i]=h1+ans2[i-1];
            else ans2[i]=ans2[i-1]-h1;
        }
        else
        {
            if(ans1[i-1]<ans1[i-2])ans1[i]=h1+ans1[i-1];
            else ans1[i]=ans1[i-1]-h1;
            if(ans2[i-1]<ans2[i-2])ans2[i]=h1+ans2[i-1];
            else ans2[i]=ans2[i-1]-h1;
        }
        if(ans1[i]<mn1){mn1=min(mn1, ans1[i]); mnp1=i;}
        if(ans2[i]<mn2){mn2=min(mn2, ans2[i]); mnp2=i;}
        if(ans1[i]>mx1){mx1=max(mx1, ans1[i]); mxp1=i;}
        if(ans2[i]>mx2){mx2=max(mx2, ans2[i]); mxp2=i;}
        hlast=h1;
    }
    if(mxp1>mnp1)
    {
        for(int i=1; i<=N; i++)answer(i, ans1[i]-mn1+1);
    }
    else
    {
        for(int i=1; i<=N; i++)answer(i, ans2[i]-mn2+1);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -