This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |