제출 #158169

#제출 시각아이디문제언어결과실행 시간메모리
158169fedoseevtimofeyWorst Reporter 3 (JOI18_worst_reporter3)C++14
12 / 100
473 ms13180 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1007;
const int T = 1007;

int pos[T][N];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, q;
    cin >> n >> q;
    vector <int> d(n + 1);
    for (int i = 1; i <= n; ++i) cin >> d[i];   
    d[0] = 1;
    ++n;
    for (int i = 0; i < n; ++i) pos[0][i] = -i;
    for (int t = 1; t < T; ++t) {
        for (int i = 0; i < n; ++i) {
            pos[t][i] = pos[t - 1][i];
        }
        ++pos[t][0];
        for (int i = 1; i < n; ++i) {
            if (pos[t][i - 1] - pos[t][i] > d[i]) {
                pos[t][i] = pos[t][i - 1] - 1;
            }
        }
    }
    while (q--) {
        int t, l, r;
        cin >> t >> l >> r;
        int ans = 0;
        for (int i = 0; i < n; ++i) if (l <= pos[t][i] && pos[t][i] <= r) ++ans;
        cout << ans << '\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...