이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ll ceil(ll x, ll y) {
return (x + y - 1) / y;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n, q;
cin >> n >> q;
vector<pair<int, ll>> 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) {
ll t, l, r;
cin >> t >> l >> r;
auto cmp = [&] (const pii& elem, ll 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... |