Submission #797877

# Submission time Handle Problem Language Result Execution time Memory
797877 2023-07-30T04:35:30 Z vjudge1 Worst Reporter 3 (JOI18_worst_reporter3) C++17
100 / 100
1323 ms 29176 KB
#include <bits/stdc++.h>

#define fi first
#define se second

const int N = 500500;
const int mod = 1e9 + 7;

using namespace std;

int n;
int q;
long long d[N];
long long f[N];

long long get(int i, long long t)
{
    return t / f[i] * f[i] - i;
}

int solve(long long k, long long t)
{
    int l = 0, r = n + 1;
    while (l < r) {
        int m = (l + r) / 2;
        if (get(m, t) <= k) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    return n - l + 1;
}

int main() {
    #ifdef zxc
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n >> q;
    f[0] = 1;
    for (int i = 1; i <= n; i++) {
        cin >> d[i];
        f[i] = ((d[i] - 1) / f[i - 1] + 1) * f[i - 1];
    }
    for (int i = 1; i <= q; i++) {
        long long l, r, t;
        cin >> t >> l >> r;
        cout << solve(r, t) - solve(l - 1, t) << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1253 ms 26556 KB Output is correct
2 Correct 1245 ms 26472 KB Output is correct
3 Correct 1323 ms 26516 KB Output is correct
4 Correct 1250 ms 26528 KB Output is correct
5 Correct 1270 ms 26632 KB Output is correct
6 Correct 1241 ms 26568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 316 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 320 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1253 ms 26556 KB Output is correct
2 Correct 1245 ms 26472 KB Output is correct
3 Correct 1323 ms 26516 KB Output is correct
4 Correct 1250 ms 26528 KB Output is correct
5 Correct 1270 ms 26632 KB Output is correct
6 Correct 1241 ms 26568 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 316 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 320 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1072 ms 25124 KB Output is correct
14 Correct 1087 ms 25752 KB Output is correct
15 Correct 1060 ms 24268 KB Output is correct
16 Correct 1078 ms 24804 KB Output is correct
17 Correct 1197 ms 29072 KB Output is correct
18 Correct 1190 ms 29120 KB Output is correct
19 Correct 1216 ms 29168 KB Output is correct
20 Correct 1190 ms 28992 KB Output is correct
21 Correct 1208 ms 29108 KB Output is correct
22 Correct 1188 ms 29176 KB Output is correct
23 Correct 1195 ms 29060 KB Output is correct
24 Correct 1201 ms 29136 KB Output is correct
25 Correct 1255 ms 26484 KB Output is correct
26 Correct 1256 ms 26528 KB Output is correct
27 Correct 1242 ms 28780 KB Output is correct
28 Correct 1203 ms 28928 KB Output is correct
29 Correct 1208 ms 28456 KB Output is correct
30 Correct 1230 ms 28652 KB Output is correct
31 Correct 1232 ms 28868 KB Output is correct
32 Correct 1139 ms 25172 KB Output is correct
33 Correct 0 ms 212 KB Output is correct