Submission #411840

# Submission time Handle Problem Language Result Execution time Memory
411840 2021-05-26T06:04:55 Z ParsaAlizadeh Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
720 ms 29252 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define X first
#define Y second

inline ll ceil(ll x, ll y) {
    return (x + y - 1) / y;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<pair<int, ll>> D(n + 1);
    D[0] = {0, 1};
    for (int i = 1; i <= n; i++) {
        cin >> D[i].Y;
        D[i].X = -i;
        D[i].Y = ceil(D[i].Y, D[i - 1].Y) * D[i - 1].Y;
    }
    while (q --> 0) {
        ll t, l, r;
        cin >> t >> l >> r;
        auto cmp = [&] (const pii& elem, ll r) -> bool {
            int k = t / elem.Y * elem.Y + elem.X;
            return k >= r;
        };
        int ans = lower_bound(begin(D), end(D), l, cmp) - lower_bound(begin(D), end(D), r + 1, cmp);
        cout << ans << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 702 ms 11120 KB Output is correct
2 Correct 680 ms 11032 KB Output is correct
3 Correct 700 ms 11132 KB Output is correct
4 Correct 668 ms 11076 KB Output is correct
5 Correct 685 ms 11076 KB Output is correct
6 Correct 684 ms 11128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 702 ms 11120 KB Output is correct
2 Correct 680 ms 11032 KB Output is correct
3 Correct 700 ms 11132 KB Output is correct
4 Correct 668 ms 11076 KB Output is correct
5 Correct 685 ms 11076 KB Output is correct
6 Correct 684 ms 11128 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 392 ms 25044 KB Output is correct
14 Correct 392 ms 25756 KB Output is correct
15 Correct 378 ms 24320 KB Output is correct
16 Correct 384 ms 24972 KB Output is correct
17 Correct 517 ms 29252 KB Output is correct
18 Correct 495 ms 29184 KB Output is correct
19 Correct 480 ms 29208 KB Output is correct
20 Correct 491 ms 29128 KB Output is correct
21 Correct 560 ms 29244 KB Output is correct
22 Correct 488 ms 29128 KB Output is correct
23 Correct 559 ms 29132 KB Output is correct
24 Correct 508 ms 29208 KB Output is correct
25 Correct 684 ms 26624 KB Output is correct
26 Correct 720 ms 26620 KB Output is correct
27 Correct 557 ms 28808 KB Output is correct
28 Correct 533 ms 28984 KB Output is correct
29 Correct 548 ms 28552 KB Output is correct
30 Correct 565 ms 28644 KB Output is correct
31 Correct 559 ms 28992 KB Output is correct
32 Correct 552 ms 25192 KB Output is correct
33 Correct 1 ms 204 KB Output is correct