# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44370 | RayaBurong25_1 | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 944 ms | 9516 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 <stdio.h>
#include <algorithm>
int D[500005];
int E[500005];
int T;
typedef struct node node;
struct node
{
int i;
};
node V[500005];
int comp1(node element, int value)
{
return (T/E[element.i]*E[element.i] - element.i) < value;
}
int comp2(int value, node element)
{
return (T/E[element.i]*E[element.i] - element.i) > value;
}
int main()
{
int N, Q;
scanf("%d %d", &N, &Q);
int i;
D[0] = 1;
E[0] = 1;
for (i = 1; i <= N; i++)
{
scanf("%d", &D[i]);
E[i] = ((D[i] - 1)/E[i - 1] + 1)*E[i - 1];
// printf("E%d\n", E[i]);
}
for (i = 0; i <= N; i++)
V[i].i = N - i;
int L, R;
int l, r;
int j;
for (i = 0; i < Q; i++)
{
scanf("%d %d %d", &T, &L, &R);
l = std::lower_bound(&V[0], &V[N + 1], L, comp1) - &V[0];
r = std::upper_bound(&V[0], &V[N + 1], R, comp2) - &V[0];
// for (j = 0; j <= N; j++)
// printf("#%d\n", T/E[j]*E[j] - j);
// printf("l%d r%d\n", l, r);
printf("%d\n", r - l);
}
}
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... |