Submission #127729

#TimeUsernameProblemLanguageResultExecution timeMemory
127729RockyBWorst Reporter 3 (JOI18_worst_reporter3)C++17
12 / 100
2036 ms80644 KiB
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define pp pop_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define rep(a, b, c) for (int a = (b); (a) <= (c); ++a) #define per(a, b, c) for (int a = (b); (a) >= (c); --a) #define nl '\n' #define ioi exit(0); using namespace std; const int MAX_N = (int)5e5 + 7; int n, q; int d[MAX_N], l[MAX_N], r[MAX_N], t[MAX_N], ans[MAX_N]; map <int, vector <int> > off; vector <int> a; void move() { a.back()++; per(i, n - 1, 0) { if (a[i + 1] - a[i] > d[n - i]) a[i] = a[i + 1] - 1; } } int main() { #ifdef IOI freopen ("in.txt", "r", stdin); #endif ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> q; rep(i, 1, n) { cin >> d[i]; } rep(i, 1, q) { cin >> t[i] >> l[i] >> r[i]; off[t[i]].pb(i); } per(i, n, 1) a.pb(-i); a.pb(0); for (auto it : off) { while (a.back() < it.f) move(); for (auto i : it.s) { ans[i] = upper_bound(all(a), r[i]) - lower_bound(all(a), l[i]); } } rep(i, 1, q) { cout << ans[i] << nl; } ioi }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...