# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1267846 | SmuggingSpun | Worst Reporter 3 (JOI18_worst_reporter3) | C++20 | 362 ms | 13228 KiB |
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
typedef long long ll;
const int lim = 5e5 + 5;
int n, q, d[lim];
pair<ll, ll>period[lim];
ll f(ll r, ll t){
int low = 0, high = n, ans = n + 1;
while(low <= high){
int mid = (low + high) >> 1;
if(-mid + (t / period[mid].first) * period[mid].second <= r){
high = (ans = mid) - 1;
}
else{
low = mid + 1;
}
}
return ans;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> q;
for(int i = 1; i <= n; i++){
cin >> d[i];
}
period[0] = make_pair(1, 1);
for(int i = 1; i <= n; i++){
period[i].first = 1LL * ((d[i] - 1) / period[i - 1].second + 1) * period[i - 1].second;
period[i].second = 1LL * (period[i].first / period[i - 1].first) * period[i - 1].second;
}
for(int _ = 0; _ < q; _++){
int t, l, r;
cin >> t >> l >> r;
cout << f(l - 1, t) - f(r, t) << "\n";
}
}
컴파일 시 표준 에러 (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... |