# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
528834 | LucaDantas | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 2 ms | 460 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 1e3+10;
struct Query { int l, r, t, id; } qr[maxn];
int d[maxn], pos[maxn], ANS[maxn];
int main() {
int n, q; scanf("%d %d", &n, &q);
d[0] = 1;
for(int i = 1; i <= n; i++)
scanf("%d", d+i);
for(int i = 0; i < q; i++)
scanf("%d %d %d", &qr[i].t, &qr[i].l, &qr[i].r), qr[i].id = i;
sort(qr, qr+n, [](Query a, Query b) { return a.t < b.t; });
for(int i = 1; i <= n; i++)
pos[i] = -i;
int tempo = 0;
for(int i = 0; i < q; i++) {
while(tempo < qr[i].t) {
++tempo;
pos[0]++;
for(int j = 1; j <= n; j++)
if(pos[j-1] - pos[j] > d[j]) pos[j] = pos[j-1] - 1;
else break;
}
int ans = 0;
for(int j = 0; j <= n; j++) {
if(pos[j] >= qr[i].l && pos[j] <= qr[i].r) ++ans;
// printf("%d ", pos[j]);
}
// puts("");
ANS[qr[i].id] = ans;
}
for(int i = 0; i < q; i++)
printf("%d\n", ANS[i]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |