Submission #798460

#TimeUsernameProblemLanguageResultExecution timeMemory
798460vjudge1Worst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
438 ms25288 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...