이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
 #define int long long
#define pii pair <int, int>
#define pb push_back
const int N = 5e5 + 5;
int t,n,a[N], q, per[N], d[N];
int get_pos(int x, int tm) {
	return (tm / per[x]) * per[x] - x;
}
main() {
	std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>q;
	for (int i = 1; i <= n; i++) {
		cin>>d[i];
	}
	per[0] = 1; per[1] = d[1];
	for (int i = 2; i <= n; i++) {
		per[i] = (d[i] + per[i - 1] - 1) / per[i - 1] * per[i - 1];
	}
	while (q--) {
		int t, l, r;
		cin>>t>>l>>r;
		int le = 0, ri = n, ans = -1, ans1 = n + 1;
		while (le <= ri) {
			int mid = (le + ri) / 2;
			if (get_pos(mid, t) >= l) {
				ans = mid;
				le = mid + 1;
			} else ri = mid - 1;
		}
		le = 0, ri = n;
		while (le <= ri) {
			int mid = (le + ri) / 2;
			if (get_pos(mid, t) <= r) {
				ans1 = mid; ri = mid - 1;
			} else le = mid + 1;
		}
		cout<<max(ans - ans1 + 1, 0LL)<<"\n";
	}
}
컴파일 시 표준 에러 (stderr) 메시지
worst_reporter3.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | 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... |