Submission #797892

# Submission time Handle Problem Language Result Execution time Memory
797892 2023-07-30T05:24:27 Z vjudge1 Worst Reporter 3 (JOI18_worst_reporter3) C++17
19 / 100
174 ms 22976 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int M = 1e3 + 10;
const int N = 5e5 + 10;

int n, q;
ll d[N], T[N], L[N], R[N];

struct query {
    ll l, r, i, t;
};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> q;
    for(int i = 1; i <= n; i++) 
        cin >> d[i];
    for(int i = 1; i <= q; i++) {
        cin >> T[i] >> L[i] >> R[i];
    }
    ll D[n + 1] = {};
    D[0] = 1;
    for(int i = 1; i <= n; i++) 
        D[i] = D[i - 1] * ((d[i] + D[i - 1] - 1)/ D[i - 1]);
    if(n <= 1000 && q <= 1000) {
        int ans[q + 1] = {};
        vector<query> g[M];
        for(int i = 1; i <= q; i++) {
            g[T[i]].push_back({L[i], R[i], i, T[i]});
        }
        vector<int> ar(n + 1);
        for(int i = 0; i <= n; i++) ar[i] = -i;
        for(int t = 1; t < M; t++) {
            ar[0]++;
            for(int i = 1; i <= n; i++) 
                // if(ar[i - 1] - ar[i] > d[i]) ar[i] = ar[i - 1] - 1;
                ar[i] += (ar[i - 1] - ar[i] - 1) / D[i] * D[i];
            // for(int c : ar) cout << c << ' ';
            // cout << '\n';
            for(query cur : g[t]) {
                for(int c : ar) {
                    ans[cur.i] += (cur.l <= c && c <= cur.r);
                }
            }

        }
        for(int i = 1; i <= q; i++) 
            cout << ans[i] << '\n';
        return 0;
    }
    bool flag = 1;
    for(int i = 1; i <= n; i++)
        flag &= (d[i] == 1);
    if(flag) {
        for(int i = 1; i <= q; i++) {
            ll lb = max(T[i] - n, L[i]), rb = min(T[i], R[i]);
            cout << max(rb - lb + 1, 0ll) << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 161 ms 22860 KB Output is correct
2 Correct 164 ms 22892 KB Output is correct
3 Correct 174 ms 22848 KB Output is correct
4 Correct 160 ms 22792 KB Output is correct
5 Correct 161 ms 22848 KB Output is correct
6 Correct 162 ms 22976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 468 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 7 ms 468 KB Output is correct
4 Correct 7 ms 464 KB Output is correct
5 Correct 7 ms 468 KB Output is correct
6 Correct 7 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 161 ms 22860 KB Output is correct
2 Correct 164 ms 22892 KB Output is correct
3 Correct 174 ms 22848 KB Output is correct
4 Correct 160 ms 22792 KB Output is correct
5 Correct 161 ms 22848 KB Output is correct
6 Correct 162 ms 22976 KB Output is correct
7 Correct 7 ms 468 KB Output is correct
8 Correct 7 ms 340 KB Output is correct
9 Correct 7 ms 468 KB Output is correct
10 Correct 7 ms 464 KB Output is correct
11 Correct 7 ms 468 KB Output is correct
12 Correct 7 ms 468 KB Output is correct
13 Incorrect 139 ms 19840 KB Output isn't correct
14 Halted 0 ms 0 KB -