This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
main() {
#ifdef Home
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // Home
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, q, T, L, R;
cin >> n >> q;
vector < ll > D(n + 1);
D[0] = 1;
for(int i = 1; i <= n; ++ i) {
cin >> D[i];
D[i] = D[i - 1] * ((D[i] + D[i - 1] - 1) / D[i - 1]);
}
for(ll l, r, m, _l, _r, t; q --> 0;) {
cin >> T >> L >> R;
/**
for(int i = 0; i <= n; ++ i) {
cout << T - T % D[i] - i << ' ';
}
cout << '\n';
// */
//**
l = -1, r = n + 1;
for(; l + 1 < r;) {
m = (l + r) / 2;
t = T - T % D[m] - m;
(t < L ? r : l) = m;
}
_r = l;
l = -1, r = n + 1;
for(; l + 1 < r;) {
m = (l + r) / 2;
t = T - T % D[m] - m;
(R < t ? l : r) = m;
}
_l = r;
cout << (_l <= _r ? _r - _l + 1 : 0) << '\n';
// */
}
}
Compilation message (stderr)
worst_reporter3.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
12 | main() {
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |