Submission #411838

#TimeUsernameProblemLanguageResultExecution timeMemory
411838ParsaAlizadehWorst Reporter 3 (JOI18_worst_reporter3)C++17
19 / 100
661 ms22744 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define X first #define Y second inline int ceil(int x, int y) { return (x + y - 1) / y; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector<pii> D(n + 1); D[0] = {0, 1}; for (int i = 1; i <= n; i++) { cin >> D[i].Y; D[i].X = -i; D[i].Y = ceil(D[i].Y, D[i - 1].Y) * D[i - 1].Y; } while (q --> 0) { int t, l, r; cin >> t >> l >> r; auto cmp = [&] (const pii& elem, int r) -> bool { int k = t / elem.Y * elem.Y + elem.X; return k >= r; }; int ans = lower_bound(begin(D), end(D), l, cmp) - lower_bound(begin(D), end(D), r + 1, cmp); cout << ans << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...