이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 5e5+10;
ll d[N], t[N];
int main() {
ios::sync_with_stdio(0); cin.tie(0);
ll n, q;
cin >> n >> q;
for(int i = 1; i <= n; ++i) {
cin >> d[i];
}
t[0] = 1;
for(int i = 1; i <= n; ++i) {
t[i] = (d[i]+t[i-1]-1) / t[i-1] * t[i-1];
}
auto coord = [&](ll x, ll time) -> ll {
return -x + time / t[x] * t[x];
};
auto query = [&](ll x, ll t) -> ll {
ll l = 0, r = n, ans = n+1;
while(r >= l) {
ll m = l + r >> 1;
if(coord(m, t) <= x) {
r = m - 1;
ans = m;
} else {
l = m + 1;
}
}
return n - ans + 1;
};
for(int i = 0; i < q; ++i) {
ll t, l, r;
cin >> t >> l >> r;
cout << query(r, t) - query(l - 1, t) << '\n';
}
}
컴파일 시 표준 에러 (stderr) 메시지
worst_reporter3.cpp: In lambda function:
worst_reporter3.cpp:23:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
23 | ll m = l + r >> 1;
| ~~^~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |