Submission #541040

#TimeUsernameProblemLanguageResultExecution timeMemory
541040LittleCubeFire (JOI20_ho_t5)C++14
7 / 100
292 ms14244 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define F first #define S second using namespace std; struct query { int i, T, L, R; }; ll N, Q, arr[200005], ans[200005]; query q[200005]; signed main() { cin >> N >> Q; for (int i = 1; i <= N; i++) cin >> arr[i]; for (int i = 1; i <= Q; i++) { cin >> q[i].T >> q[i].L >> q[i].R; q[i].i = i; } sort(q + 1, q + 1 + Q, [](query q1, query q2) { return q1.L < q2.L; }); int qdx = 1; vector<pll> v; for (int i = 1; i <= N; i++) { while(!v.empty() && v.back().S <= arr[i]) v.pop_back(); v.push_back(pll{i, arr[i]}); while (qdx <= Q && q[qdx].L == i) { ans[q[qdx].i] = lower_bound(v.begin(), v.end(), pll{i - q[qdx].T, 0})->S; qdx++; } } for (int i = 1; i <= Q; i++) cout << ans[i] << '\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...
#Verdict Execution timeMemoryGrader output
Fetching results...