이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector<LL> d;
vector<LL> jump;
LL get(LL t, LL pos){
// at time t how many people are >= pos;
LL s = -1; // yes
LL e = d.size(); // no
while(s + 1 < e){
LL m = (s + e) / 2;
// where is person m at certain time.
if((t / jump[m]) * jump[m] - m - 1 >= pos){
s = m;
} else {
e = m;
}
}
return e + (t >= pos);
}
int main(){
cin.sync_with_stdio(0); cin.tie(0);
LL n;
LL q;
cin >> n >> q;
d.resize(n);
jump.resize(n);
LL prev = 1;
for(int i = 0; i < n; i++){
cin >> d[i];
LL numc = (d[i] + prev - 1) / prev;
jump[i] = prev * numc;
prev = jump[i];
}
for(int i = 0; i < q; i++){
LL t, l, r;
cin >> t >> l >> r;
cout << get(t,l) - get(t,r+1) << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |