Submission #58557

#TimeUsernameProblemLanguageResultExecution timeMemory
58557gusfringXylophone (JOI18_xylophone)C++14
100 / 100
125 ms844 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 5e3 + 5; int A[MAXN], dif[MAXN]; void solve(int N){ for(int i=1; i<N; ++i) dif[i - 1] = query(i, i + 1); int sign = 1; A[0] = 0, A[1] = dif[0]; for(int i=1; i<N-1; ++i){ if(query(i, i + 2) != (dif[i - 1] + dif[i])) sign = -sign; A[i + 1] = A[i] + sign * dif[i]; } int mn = 0, mx = 0; for(int i=1; i<N; ++i){ if(A[i] < A[mn]) mn = i; if(A[i] > A[mx]) mx = i; } if(mn > mx){ for(int i=1; i<N; ++i) A[i] = -A[i]; swap(mn, mx); } for(int i=0; i<N; ++i) answer(i + 1, A[i] - A[mn] + 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...