# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642901 | valerikk | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 1702 ms | 28372 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 <cstdio>
#define MAXN 500005
#define MAXT 1005
int N, Q;
int D[MAXN];
int T[MAXN], L[MAXN], R[MAXN];
int ans[MAXN];
int a[MAXN];
int main() {
scanf("%d%d", &N, &Q);
for (int i = 1; i <= N; ++i) {
scanf("%d", &D[i]);
}
for (int i = 0; i < Q; ++i) {
scanf("%d%d%d", &T[i], &L[i], &R[i]);
}
for (int i = 0; i < Q; ++i) {
ans[i] = (T[i] >= L[i] && T[i] <= R[i]);
}
for (int t = 1; t <= MAXT; ++t) {
++a[1];
for (int i = 1; i <= N && a[i] >= D[i]; ++i) {
if (i != N)
a[i + 1] += a[i];
a[i] = 0;
}
for (int i = 0; i < Q; ++i) {
if (T[i] == t) {
int X = t;
for (int j = 1; j <= N; ++j) {
X -= a[j] + 1;
ans[i] += (X >= L[i] && X <= R[i]);
}
}
}
}
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... |