# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83444 | tincamatei | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 1022 ms | 93692 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;
const int MAX_N = 500000;
int d[1+MAX_N];
int per[1+MAX_N], jump[1+MAX_N];
int poz(int i, int t) {
return -i + t / per[i] * jump[i];
}
int binsrc(int n, int t, int val) {
int st = -1, dr = n + 1;
while(dr - st > 1) {
int mid = (st + dr) / 2;
if(poz(mid, t) <= val)
dr = mid;
else
st = mid;
}
return dr;
}
int main() {
#ifdef HOME
FILE *fin = fopen("input.in", "r");
FILE *fout = fopen("output.out", "w");
#else
FILE *fin = stdin;
FILE *fout = stdout;
#endif
int n, q, t, l, r;
fscanf(fin, "%d%d", &n, &q);
per[0] = jump[0] = 1;
for(int i = 1; i <= n; ++i) {
fscanf(fin, "%d", &d[i]);
per[i] = (d[i] + jump[i - 1] - 1) / jump[i - 1];
jump[i] = jump[i - 1] * per[i];
per[i] = per[i - 1] * per[i];
}
for(int i = 0; i < q; ++i) {
fscanf(fin, "%d%d%d", &t, &l, &r);
int a = binsrc(n, t, r), b = binsrc(n, t, l - 1);
fprintf(fout, "%d\n", b - a);
}
#ifdef HOME
fclose(fin);
fclose(fout);
#endif
return 0;
}
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... |