이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |