Submission #797892

#TimeUsernameProblemLanguageResultExecution timeMemory
797892vjudge1Worst Reporter 3 (JOI18_worst_reporter3)C++17
19 / 100
174 ms22976 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int M = 1e3 + 10; const int N = 5e5 + 10; int n, q; ll d[N], T[N], L[N], R[N]; struct query { ll l, r, i, t; }; int main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin >> n >> q; for(int i = 1; i <= n; i++) cin >> d[i]; for(int i = 1; i <= q; i++) { cin >> T[i] >> L[i] >> R[i]; } ll D[n + 1] = {}; D[0] = 1; for(int i = 1; i <= n; i++) D[i] = D[i - 1] * ((d[i] + D[i - 1] - 1)/ D[i - 1]); if(n <= 1000 && q <= 1000) { int ans[q + 1] = {}; vector<query> g[M]; for(int i = 1; i <= q; i++) { g[T[i]].push_back({L[i], R[i], i, T[i]}); } vector<int> ar(n + 1); for(int i = 0; i <= n; i++) ar[i] = -i; for(int t = 1; t < M; t++) { ar[0]++; for(int i = 1; i <= n; i++) // if(ar[i - 1] - ar[i] > d[i]) ar[i] = ar[i - 1] - 1; ar[i] += (ar[i - 1] - ar[i] - 1) / D[i] * D[i]; // for(int c : ar) cout << c << ' '; // cout << '\n'; for(query cur : g[t]) { for(int c : ar) { ans[cur.i] += (cur.l <= c && c <= cur.r); } } } for(int i = 1; i <= q; i++) cout << ans[i] << '\n'; return 0; } bool flag = 1; for(int i = 1; i <= n; i++) flag &= (d[i] == 1); if(flag) { for(int i = 1; i <= q; i++) { ll lb = max(T[i] - n, L[i]), rb = min(T[i], R[i]); cout << max(rb - lb + 1, 0ll) << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...