Submission #987776

# Submission time Handle Problem Language Result Execution time Memory
987776 2024-05-23T15:00:02 Z alextodoran Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
462 ms 27588 KB
/**
 _  _   __  _ _ _  _  _ _
 |a  ||t  ||o    d | |o  |
| __    _| | _ | __|  _ |
| __ |/_  | __  /__\ / _\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 500000;

int N, Q;
int D[N_MAX + 2];

ll F[N_MAX + 2];

ll get_pos (int t, int i) {
    return (t / F[i]) * F[i] - i;
}

int cnt_after (int t, int x) {
    int l = -1, r = N;
    while (l < r) {
        int mid = (l + r + 1) / 2;
        if (get_pos(t, mid) >= x) {
            l = mid;
        } else {
            r = mid - 1;
        }
    }
    return l + 1;
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> Q;
    F[0] = 1;
    for (int i = 1; i <= N; i++) {
        cin >> D[i];
        F[i] = F[i - 1] * ((D[i] + F[i - 1] - 1) / F[i - 1]);
    }
    while (Q--) {
        int t, l, r;
        cin >> t >> l >> r;
        cout << cnt_after(t, l) - cnt_after(t, r + 1) << "\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 420 ms 9296 KB Output is correct
2 Correct 462 ms 9244 KB Output is correct
3 Correct 452 ms 9152 KB Output is correct
4 Correct 436 ms 9300 KB Output is correct
5 Correct 435 ms 9204 KB Output is correct
6 Correct 429 ms 9088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 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 420 ms 9296 KB Output is correct
2 Correct 462 ms 9244 KB Output is correct
3 Correct 452 ms 9152 KB Output is correct
4 Correct 436 ms 9300 KB Output is correct
5 Correct 435 ms 9204 KB Output is correct
6 Correct 429 ms 9088 KB Output is correct
7 Correct 2 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 255 ms 23380 KB Output is correct
14 Correct 262 ms 23676 KB Output is correct
15 Correct 247 ms 22608 KB Output is correct
16 Correct 246 ms 23100 KB Output is correct
17 Correct 321 ms 27304 KB Output is correct
18 Correct 315 ms 27216 KB Output is correct
19 Correct 320 ms 27304 KB Output is correct
20 Correct 339 ms 27212 KB Output is correct
21 Correct 329 ms 27172 KB Output is correct
22 Correct 358 ms 27588 KB Output is correct
23 Correct 317 ms 27292 KB Output is correct
24 Correct 331 ms 27340 KB Output is correct
25 Correct 427 ms 24660 KB Output is correct
26 Correct 423 ms 24808 KB Output is correct
27 Correct 355 ms 27036 KB Output is correct
28 Correct 348 ms 26992 KB Output is correct
29 Correct 357 ms 26604 KB Output is correct
30 Correct 391 ms 26732 KB Output is correct
31 Correct 353 ms 27004 KB Output is correct
32 Correct 340 ms 23268 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct