#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 |
1 |
Correct |
656 ms |
22744 KB |
Output is correct |
2 |
Correct |
637 ms |
22664 KB |
Output is correct |
3 |
Correct |
647 ms |
22736 KB |
Output is correct |
4 |
Correct |
661 ms |
22692 KB |
Output is correct |
5 |
Correct |
635 ms |
22704 KB |
Output is correct |
6 |
Correct |
638 ms |
22680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
656 ms |
22744 KB |
Output is correct |
2 |
Correct |
637 ms |
22664 KB |
Output is correct |
3 |
Correct |
647 ms |
22736 KB |
Output is correct |
4 |
Correct |
661 ms |
22692 KB |
Output is correct |
5 |
Correct |
635 ms |
22704 KB |
Output is correct |
6 |
Correct |
638 ms |
22680 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Runtime error |
10 ms |
8312 KB |
Execution killed with signal 8 |
14 |
Halted |
0 ms |
0 KB |
- |