Submission #74669

#TimeUsernameProblemLanguageResultExecution timeMemory
74669kdh9949Xylophone (JOI18_xylophone)C++17
100 / 100
86 ms724 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; const int N = 5005; static int a[N]; void solve(int n){ a[2] = query(1, 2); for(int i = 3, x, y; i <= n; i++){ x = query(i - 2, i); y = query(i - 1, i); if((x == y + abs(a[i - 2] - a[i - 1])) ^ (a[i - 2] > a[i - 1])) a[i] = a[i - 1] + y; else a[i] = a[i - 1] - y; } if(min_element(a + 1, a + n + 1) > max_element(a + 1, a + n + 1)) for(int i = 1; i <= n; i++) a[i] *= -1; int m = *min_element(a + 1, a + n + 1); for(int i = 1; i <= n; i++) answer(i, a[i] - m + 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...