Submission #602834

# Submission time Handle Problem Language Result Execution time Memory
602834 2022-07-23T11:43:54 Z elkernos Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
573 ms 29252 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int32_t main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n, q;
    cin >> n >> q;
    vector<int> d(n + 1), f(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> d[i];
        if(i == 1) {
            f[i] = d[i];
        }
        else {
            f[i] = (d[i] + f[i - 1] - 1) / f[i - 1] * f[i - 1];
        }
    }
    auto licz = [&](int t, int x) {
        int lo = 1, hi = n, ans = 0;
        while(lo <= hi) {
            int mid = (lo + hi) / 2;
            if(t / f[mid] * f[mid] - mid >= x) {
                lo = mid + 1;
                ans = mid;
            }
            else {
                hi = mid - 1;
            }
        }
        return ans;
    };
    for(int i = 1; i <= q; i++) {
        int t, l, r;
        cin >> t >> l >> r;
        cout << licz(t, l) - licz(t, r + 1) + (l <= t && t <= r) << '\n';
    }
}

// (0, 0), (1, 1), (2, 2), (3, 3), (4, 4), ...
// (-1, 0), (d_1 - 1, d_1), (2 * d_1 - 1, 2 * d_1), ...
// (-2, 0), ()

// k*d_1 - 1 >= -2 + d_2 - 1

// k >= d_2/d_1
// (k * ceil(d_2, d_1) * d_1 - 2)

//...
# Verdict Execution time Memory Grader output
1 Correct 503 ms 26640 KB Output is correct
2 Correct 479 ms 26568 KB Output is correct
3 Correct 544 ms 26596 KB Output is correct
4 Correct 492 ms 26560 KB Output is correct
5 Correct 532 ms 26524 KB Output is correct
6 Correct 573 ms 26572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 503 ms 26640 KB Output is correct
2 Correct 479 ms 26568 KB Output is correct
3 Correct 544 ms 26596 KB Output is correct
4 Correct 492 ms 26560 KB Output is correct
5 Correct 532 ms 26524 KB Output is correct
6 Correct 573 ms 26572 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 294 ms 25028 KB Output is correct
14 Correct 300 ms 25624 KB Output is correct
15 Correct 286 ms 24292 KB Output is correct
16 Correct 291 ms 24860 KB Output is correct
17 Correct 374 ms 29140 KB Output is correct
18 Correct 393 ms 29136 KB Output is correct
19 Correct 372 ms 29160 KB Output is correct
20 Correct 389 ms 29072 KB Output is correct
21 Correct 374 ms 29128 KB Output is correct
22 Correct 355 ms 29252 KB Output is correct
23 Correct 371 ms 29044 KB Output is correct
24 Correct 368 ms 29248 KB Output is correct
25 Correct 482 ms 26520 KB Output is correct
26 Correct 489 ms 26648 KB Output is correct
27 Correct 436 ms 28784 KB Output is correct
28 Correct 389 ms 29096 KB Output is correct
29 Correct 392 ms 28620 KB Output is correct
30 Correct 399 ms 28732 KB Output is correct
31 Correct 391 ms 29000 KB Output is correct
32 Correct 375 ms 25164 KB Output is correct
33 Correct 1 ms 212 KB Output is correct