Submission #895912

# Submission time Handle Problem Language Result Execution time Memory
895912 2023-12-31T04:35:59 Z hmm789 Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
483 ms 25392 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1000000000000000000
#define MOD 998244353

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, q, t, l, r;
    cin >> n >> q;
    int a[n+1];
    a[0] = 1;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] = (a[i]+a[i-1]-1)/a[i-1]*a[i-1];
    }
    while(q--) {
        cin >> t >> l >> r;
        int L = 0, R = n+1, m;
        while(L < R) {
            m = (L+R)/2;
            int pos = -m+t/a[m]*a[m];
            if(pos > r) L = m+1;
            else R = m;
        }
        int rpos = L;
        L = 0; R = n+1;
        while(L < R) {
            m = (L+R)/2;
            int pos = -m+t/a[m]*a[m];
            if(pos >= l) L = m+1;
            else R = m;
        }
        int lpos = L;
        cout << lpos-rpos << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 480 ms 22688 KB Output is correct
2 Correct 475 ms 22780 KB Output is correct
3 Correct 471 ms 22636 KB Output is correct
4 Correct 454 ms 22716 KB Output is correct
5 Correct 483 ms 22772 KB Output is correct
6 Correct 483 ms 22832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 480 ms 22688 KB Output is correct
2 Correct 475 ms 22780 KB Output is correct
3 Correct 471 ms 22636 KB Output is correct
4 Correct 454 ms 22716 KB Output is correct
5 Correct 483 ms 22772 KB Output is correct
6 Correct 483 ms 22832 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 259 ms 21240 KB Output is correct
14 Correct 263 ms 21748 KB Output is correct
15 Correct 256 ms 20332 KB Output is correct
16 Correct 258 ms 21072 KB Output is correct
17 Correct 334 ms 25300 KB Output is correct
18 Correct 327 ms 25328 KB Output is correct
19 Correct 347 ms 25272 KB Output is correct
20 Correct 347 ms 25260 KB Output is correct
21 Correct 343 ms 25392 KB Output is correct
22 Correct 338 ms 25204 KB Output is correct
23 Correct 350 ms 25324 KB Output is correct
24 Correct 340 ms 25296 KB Output is correct
25 Correct 470 ms 22768 KB Output is correct
26 Correct 458 ms 22772 KB Output is correct
27 Correct 379 ms 24716 KB Output is correct
28 Correct 380 ms 25208 KB Output is correct
29 Correct 383 ms 24756 KB Output is correct
30 Correct 381 ms 24980 KB Output is correct
31 Correct 388 ms 25120 KB Output is correct
32 Correct 354 ms 21428 KB Output is correct
33 Correct 1 ms 348 KB Output is correct