제출 #1159765

#제출 시각아이디문제언어결과실행 시간메모리
1159765gelastropodSpecijacija (COCI20_specijacija)C++20
10 / 110
4094 ms2492 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n, q, t, a, b; cin >> n >> q >> t; vector<int> A; for (int i = 0; i < n; i++) { cin >> a; a--; A.push_back(a); } for (int i = 0; i < q; i++) { cin >> a >> b; a--, b--; while (a != b) { int ka = (1 + pow(1 + 8 * a, 0.5f)) / 2; int kb = (1 + pow(1 + 8 * b, 0.5f)) / 2; if (ka < kb) { b -= kb; if (b < A[kb - 2]) b++; } else if (ka > kb) { a -= ka; if (a < A[ka - 2]) a++; } else { b -= kb; if (b < A[kb - 2]) b++; a -= ka; if (a < A[ka - 2]) a++; } } cout << a + 1 << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...