Submission #997917

# Submission time Handle Problem Language Result Execution time Memory
997917 2024-06-13T06:32:17 Z juliany2 Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
543 ms 29264 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()

const int N = 5e5 + 7;
int n, q;
ll d[N], c[N];

int main() {
    cin.tie(0)->sync_with_stdio(false);

    cin >> n >> q;

    c[0] = 1;
    for (int i = 1; i <= n; i++) {
        cin >> d[i];

        c[i] = (d[i] + c[i - 1] - 1) / c[i - 1] * c[i - 1];
    }

    auto query = [&](ll t, ll x) {
        ll res = n + 1, shift = 0;;

        while (t > 0) {
            int i = upper_bound(c, c + n + 1, t) - c - 1;

            ll dist = t - (t % c[i]);
            t -= dist, shift += dist;

            res = min(res, n + 1 - i + max(x - (shift - i), -1LL));
        }

        return res;
    };

    while (q--) {
        ll t, l, r;
        cin >> t >> l >> r;

        cout << query(t, r) - query(t, l - 1) << '\n';
    }

    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 168 ms 26704 KB Output is correct
2 Correct 159 ms 26700 KB Output is correct
3 Correct 209 ms 26700 KB Output is correct
4 Correct 169 ms 26560 KB Output is correct
5 Correct 158 ms 26708 KB Output is correct
6 Correct 167 ms 26708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 168 ms 26704 KB Output is correct
2 Correct 159 ms 26700 KB Output is correct
3 Correct 209 ms 26700 KB Output is correct
4 Correct 169 ms 26560 KB Output is correct
5 Correct 158 ms 26708 KB Output is correct
6 Correct 167 ms 26708 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 169 ms 25044 KB Output is correct
14 Correct 178 ms 25680 KB Output is correct
15 Correct 158 ms 24364 KB Output is correct
16 Correct 171 ms 25052 KB Output is correct
17 Correct 412 ms 29260 KB Output is correct
18 Correct 369 ms 29012 KB Output is correct
19 Correct 401 ms 29264 KB Output is correct
20 Correct 399 ms 29264 KB Output is correct
21 Correct 402 ms 29124 KB Output is correct
22 Correct 399 ms 29160 KB Output is correct
23 Correct 379 ms 29008 KB Output is correct
24 Correct 408 ms 29180 KB Output is correct
25 Correct 179 ms 26548 KB Output is correct
26 Correct 169 ms 26704 KB Output is correct
27 Correct 422 ms 28752 KB Output is correct
28 Correct 444 ms 29044 KB Output is correct
29 Correct 447 ms 28752 KB Output is correct
30 Correct 543 ms 28756 KB Output is correct
31 Correct 471 ms 29012 KB Output is correct
32 Correct 154 ms 25200 KB Output is correct
33 Correct 0 ms 2392 KB Output is correct