# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
242213 | SomeoneUnknown | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 792 ms | 5624 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;
int posof(int slow, int id, int tiem){
//printf("%d at pos %d at time %d\n", id, (tiem/slow)*slow-id, tiem);
return (tiem/slow)*slow-id;
}
int main(){
int n, q;
scanf("%d %d", &n, &q);
int dancers[n+1];
dancers[0] = 1;
for(int i = 0; i < n; ++i){
scanf("%d", &dancers[i+1]);
--dancers[i+1];
dancers[i+1] /= dancers[i];
++dancers[i+1];
dancers[i+1] *= dancers[i];
}
for(int i = 0; i < q; ++i){
int t,s,e;
scanf("%d %d %d", &t, &s, &e);
++e;
int lo, hi;
//Find how many dancers are after the end
lo = -1;
hi = n+1;
int mid;
while(hi-lo>1){
mid = (hi+lo)/2;
if(posof(dancers[mid],mid,t) < e){
hi = mid;
}else{
lo = mid;
}
}
e = hi;
//Find how many dancers are after the start
lo = -1;
hi = n+1;
while(hi-lo>1){
mid = (hi+lo)/2;
if(posof(dancers[mid],mid,t) < s){
hi = mid;
}else{
lo = mid;
}
}
s = hi;
printf("%d\n",s-e);
}
}
/*
3 6
2
5
3
1 2 4
2 2 4
3 2 4
4 2 4
5 2 4
6 2 4
*/
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... |