Submission #797879

# Submission time Handle Problem Language Result Execution time Memory
797879 2023-07-30T04:43:23 Z vjudge1 Worst Reporter 3 (JOI18_worst_reporter3) C++17
12 / 100
148 ms 15944 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];
    }

    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(!i || ar[i - 1] - ar[i] > d[i]) ar[i] = ar[i - 1] - 1;
            // 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;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 15944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 396 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 340 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 15944 KB Output isn't correct
2 Halted 0 ms 0 KB -