이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define isz(x) (int)x.size()
using namespace std;
const int mxN = 5e5 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18;
int n, q, speed[mxN];
void solve() {
    cin >> n >> q; speed[0] = 1;
    for(int i = 1; i <= n; ++i) {
        int val; cin >> val;
        if(speed[i - 1] == mod) {
            speed[i] = mod;
            continue;
        }
        int needed = val / speed[i - 1];
        if(needed * speed[i - 1] < val) ++needed;
        if(mod / needed < speed[i - 1]) speed[i] = mod;
        else speed[i] = speed[i - 1] * needed;
    }
    for(int i = 1; i <= q; ++i) {
        int t, l, r; cin >> t >> l >> r;
        int tl = 0, tr = n, ansl = -1, ansr = -1;
        while(tl <= tr) {
            int mid = (tl + tr) >> 1;
            if(speed[mid] == -1) tr = mid - 1;
            else {
                int len = (t / speed[mid]) * speed[mid] - mid;
                if(len >= l) tl = mid + 1;
                else tr = mid - 1;
            }
        }
        if(tr < 0) {
            cout << 0 << "\n";
            continue;
        }
        else ansl = tr;
        tl = 0, tr = n;
        while(tl <= tr) {
            int mid = (tl + tr) >> 1;
            if(speed[mid] == -1) tr = mid - 1;
            else {
                int len = (t / speed[mid]) * speed[mid] - mid;
                // cout << len << " " << t << " " << speed[mid] << endl;
                if(len <= r) tr = mid - 1;
                else tl = mid + 1;
            }
        }
        // cout << ansl << " " << tl << endl;
        if(tl > ansl) cout << 0 << "\n";
        else cout << ansl - tl + 1 << "\n";
    }
}
signed main() {
#ifndef CDuongg
    if(fopen(taskname".inp", "r"))
        assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
    freopen("bai3.inp", "r", stdin);
    freopen("bai3.out", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1; //cin >> t;
    while(t--) solve();
#ifdef CDuongg
    auto end = chrono::high_resolution_clock::now();
    cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
    cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
#endif
}
컴파일 시 표준 에러 (stderr) 메시지
worst_reporter3.cpp: In function 'void solve()':
worst_reporter3.cpp:43:40: warning: unused variable 'ansr' [-Wunused-variable]
   43 |         int tl = 0, tr = n, ansl = -1, ansr = -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... |