제출 #736069

#제출 시각아이디문제언어결과실행 시간메모리
736069rxlfd314Xylophone (JOI18_xylophone)C++17
0 / 100
2 ms296 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; void solve(int N) { int A[N+1], B[N+1]; A[1] = B[1] = 500069; int ma = 1, mb = 1; for (int i = 2; i <= N; i++) { int q1 = query(i-1, i); if (i == 2) { A[2] = A[1] + q1; B[2] = B[1] - q1; } else { int q2 = query(i-2, i); if (A[i-2] < A[i-1]) { if (q2 == q1 + A[i-1] - A[i-2]) { A[i] = A[i-1] + q1; B[i] = B[i-1] - q1; } else { A[i] = A[i-1] - q1; B[i] = B[i-1] + q1; } } else { if (q2 == q1 + A[i-2] - A[i-1]) { A[i] = A[i-1] - q1; B[i] = B[i-1] + q1; } else { A[i] = A[i-1] + q1; B[i] = B[i-1] - q1; } } } ma = A[ma] > A[i] ? i : ma; mb = B[mb] > B[i] ? i : mb; } if (ma < mb) { int sub = A[ma] - 1; for (int i = 1; i <= N; i++) { answer(i, A[i] - sub); } } else { int sub = B[ma] - 1; for (int i = 1; i <= N; i++) { answer(i, B[i] - sub); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...