Submission #1116811

#TimeUsernameProblemLanguageResultExecution timeMemory
1116811mmkXylophone (JOI18_xylophone)C++17
0 / 100
5 ms336 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; int a[5000]; void solve(int N) { a[1] = 0; a[2] = a[1] + query(1,2); int menor = 2*N, maior = -2*N; int minPos = 0, maxPos = 0; for(int i = 2; i < N; i++) { int d12 = query(i-1,i); int d23 = query(i,i+1); int d13 = query(i-1,i+1); int sign = (a[i] - a[i-1])/d12; if(d13 == d12 + d23) a[i+1] = a[i-1] + sign*(d13); else a[i+1] = a[i] - sign*(d23); } for(int i = 1; i <= N; i++) { if(a[i] < menor) { menor = a[i]; minPos = i; } if(a[i] > maior) { maior = a[i]; maxPos = i; } } int dif = 1 - menor; if(minPos < maxPos) { for(int i = 1; i <= N; i++) answer(i,a[i] + dif); } else { for(int i = N; i >= 1; i--) answer(i,a[i] + dif); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...