Submission #53793

#TimeUsernameProblemLanguageResultExecution timeMemory
53793Alexa2001Worst Reporter 3 (JOI18_worst_reporter3)C++17
19 / 100
1176 ms106992 KiB
#include <bits/stdc++.h> using namespace std; const int lim = 1e9; const int Nmax = 5e5 + 5; typedef long long ll; int tmp, x, y, up, D, i, N, Q, n, F, S, cnt; int d[Nmax], t[Nmax], start[Nmax], finish[Nmax]; int main() { // freopen("input", "r", stdin); // freopen("output", "w", stdout); cin.sync_with_stdio(false); cin >> N >> Q; n = 1, t[1] = 1, d[1] = 1; for(i=1; i<=N; ++i) { cin >> D; up = D / d[n]; if(D % d[n]) ++up; if((ll) up * t[n] > lim || (ll) up * d[n] > lim) break; if(up == 1) start[n] --; else { ++n; start[n] = finish[n] = -i; t[n] = t[n-1] * up; d[n] = d[n-1] * up; } } while(Q--) { cin >> tmp >> x >> y; int ans = 0; for(i=1; i<=n; ++i) { cnt = tmp / t[i]; S = start[i] + cnt * d[i]; F = finish[i] + cnt * d[i]; ans += max(0, min(y, F) - max(x, S) + 1); } cout << ans << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...