# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
242200 | dwsc | Worst Reporter 3 (JOI18_worst_reporter3) | C++14 | 705 ms | 22888 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>
#define int long long
using namespace std;
main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,q;
cin >> n >> q;
int arr[n+1];
arr[0] = 1;
for (int i = 1; i <= n; i++){
cin >> arr[i];
arr[i] = ((arr[i]+arr[i-1]-1)/arr[i-1])*arr[i-1];
//cout << arr[i] << "\n";
}
for (int i = 0; i < q; i++){
int l,r,t;
cin >> t>> l >> r;
int lo1 = 0,hi1 = n+1;
int ans1 = -1;
while (lo1 != hi1){
int m = (lo1+hi1)/2;
int travel = (t/arr[m])*arr[m];
int newcoord = -m+travel;
if (newcoord <= r){
hi1 = m;
ans1 = m;
}
else{
lo1 = m+1;
}
}
int lo2 = 0,hi2 = n+1;
int ans2 = -1;
while (lo2 != hi2){
int m = (lo2+hi2)/2;
int travel = (t/arr[m])*arr[m];
int newcoord = -m+travel;
if (newcoord >= l){
lo2 = m+1;
ans2 = m;
}
else{
hi2 = m;
}
}
// cout << ans1 << " " << ans2 << "hi\n";
cout << max(ans2-ans1+1,0LL) << "\n";
}
}
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... |