Submission #749113

# Submission time Handle Problem Language Result Execution time Memory
749113 2023-05-27T11:07:06 Z stevancv Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
309 ms 25356 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 5e5 + 2;
const int inf = 1e9;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, Q;
    cin >> n >> Q;
    vector<int> d(n), koef(n);
    for (int i = 0; i < n; i++) cin >> d[i];
    koef[0] = d[0];
    for (int i = 1; i < n; i++) {
        ll o = (d[i] - 1) / koef[i - 1];
        ll u = (ll) (koef[i - 1]) * (o + 1);
        if (u > 1e9) {
            for (int zz = 0; zz < n - i; zz++) {
                d.pop_back();
                koef.pop_back();
            }
            break;
        }
        koef[i] = koef[i - 1] * (o + 1);
    }
    n = d.size();
    vector<int> gde;
    gde.push_back(0);
    for (int i = 1; i < n; i++) if (koef[i] > koef[i - 1]) gde.push_back(i);
    int sz = gde.size();
    while (Q--) {
        int t, l, r;
        cin >> t >> l >> r;
        int ans = 0;
        for (int ii = 0; ii < sz; ii++) {
            int i = gde[ii]; int kr = (ii == sz - 1 ? n : gde[ii + 1]) - 1;
            int w = (t / koef[i]) * koef[i];
            int p = w - i - 1; int q = w - kr - 1;
            smax(q, l);
            smin(p, r);
            ans += max(0, min(p, r) - max(q, l) + 1);
        }
        ans += (l <= t && t <= r);
        cout << ans << en;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 211 ms 22904 KB Output is correct
2 Correct 215 ms 22716 KB Output is correct
3 Correct 221 ms 22600 KB Output is correct
4 Correct 213 ms 22648 KB Output is correct
5 Correct 208 ms 22748 KB Output is correct
6 Correct 207 ms 22648 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 292 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 211 ms 22904 KB Output is correct
2 Correct 215 ms 22716 KB Output is correct
3 Correct 221 ms 22600 KB Output is correct
4 Correct 213 ms 22648 KB Output is correct
5 Correct 208 ms 22748 KB Output is correct
6 Correct 207 ms 22648 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 292 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 207 ms 21124 KB Output is correct
14 Correct 218 ms 21792 KB Output is correct
15 Correct 206 ms 20428 KB Output is correct
16 Correct 213 ms 21012 KB Output is correct
17 Correct 289 ms 25192 KB Output is correct
18 Correct 291 ms 25224 KB Output is correct
19 Correct 297 ms 25340 KB Output is correct
20 Correct 297 ms 25260 KB Output is correct
21 Correct 283 ms 25204 KB Output is correct
22 Correct 283 ms 25332 KB Output is correct
23 Correct 282 ms 25208 KB Output is correct
24 Correct 283 ms 25356 KB Output is correct
25 Correct 215 ms 22692 KB Output is correct
26 Correct 214 ms 22708 KB Output is correct
27 Correct 289 ms 24772 KB Output is correct
28 Correct 308 ms 25156 KB Output is correct
29 Correct 301 ms 24792 KB Output is correct
30 Correct 300 ms 24840 KB Output is correct
31 Correct 309 ms 25088 KB Output is correct
32 Correct 212 ms 21256 KB Output is correct
33 Correct 0 ms 212 KB Output is correct