Submission #482499

# Submission time Handle Problem Language Result Execution time Memory
482499 2021-10-25T02:24:58 Z Rainbowbunny Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
510 ms 25412 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 500005;

int n, q;
long long d[MAXN];

long long Get(long long id, long long t)
{
    long long k = t / d[id];
    return -id + d[id] * k;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> q;
    d[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        cin >> d[i];
        long long g = (d[i] + d[i - 1] - 1) / d[i - 1] * d[i - 1];
        d[i] = g;
    }
    while(q--)
    {
        long long t, l, r;
        cin >> t >> l >> r;
        long long ll = 0, rr = n;
        while(ll < rr)
        {
            long long mid = (ll + rr) >> 1;
            if(Get(mid, t) > r)
            {
                ll = mid + 1;
            }
            else
            {
                rr = mid;
            }
        }
        if(Get(ll, t) > r)
        {
            cout << 0 << '\n';
        }
        else
        {
            if(Get(ll, t) < l)
            {
                cout << 0 << '\n';
            }
            else
            {
                long long l2 = ll, r2 = n;
                while(l2 < r2)
                {
                    long long mid = (l2 + r2 + 1) >> 1;
                    if(Get(mid, t) < l)
                    {
                        r2 = mid - 1;
                    }
                    else
                    {
                        l2 = mid;
                    }
                }
                cout << (l2 - ll + 1) << '\n';
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 490 ms 22760 KB Output is correct
2 Correct 497 ms 22864 KB Output is correct
3 Correct 502 ms 22708 KB Output is correct
4 Correct 483 ms 22596 KB Output is correct
5 Correct 510 ms 22660 KB Output is correct
6 Correct 494 ms 22708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 490 ms 22760 KB Output is correct
2 Correct 497 ms 22864 KB Output is correct
3 Correct 502 ms 22708 KB Output is correct
4 Correct 483 ms 22596 KB Output is correct
5 Correct 510 ms 22660 KB Output is correct
6 Correct 494 ms 22708 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 283 ms 21320 KB Output is correct
14 Correct 284 ms 21704 KB Output is correct
15 Correct 263 ms 20372 KB Output is correct
16 Correct 293 ms 20932 KB Output is correct
17 Correct 388 ms 25308 KB Output is correct
18 Correct 371 ms 25248 KB Output is correct
19 Correct 383 ms 25412 KB Output is correct
20 Correct 382 ms 25280 KB Output is correct
21 Correct 387 ms 25284 KB Output is correct
22 Correct 398 ms 25288 KB Output is correct
23 Correct 394 ms 25200 KB Output is correct
24 Correct 378 ms 25328 KB Output is correct
25 Correct 499 ms 22636 KB Output is correct
26 Correct 486 ms 22600 KB Output is correct
27 Correct 428 ms 24764 KB Output is correct
28 Correct 442 ms 25136 KB Output is correct
29 Correct 423 ms 24648 KB Output is correct
30 Correct 444 ms 24772 KB Output is correct
31 Correct 423 ms 25028 KB Output is correct
32 Correct 423 ms 21296 KB Output is correct
33 Correct 1 ms 204 KB Output is correct