# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
774909 | SteGG | Worst Reporter 3 (JOI18_worst_reporter3) | C++17 | 21 ms | 2260 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e5 + 5;
int n, q;
int f[maxn];
int d[maxn];
void open(){
if(fopen("input.inp", "r")){
freopen("input.inp", "r", stdin);
}
}
signed main(){
open();
cin >> n >> q;
for(int i = 1; i <= n; i++){
cin >> d[i];
}
f[0] = 1;
for(int i = 1; i <= n; i++){
f[i] = ceil((double)(d[i]) / (double)(f[i - 1])) * f[i - 1];
}
auto get = [&](int pos, int t){
return t / f[pos] * f[pos] - pos;
};
auto bin_sex = [&](int limit, int t){
int s = 0, e = n;
int ans = -1;
while(s <= e){
int mid = (s + e) >> 1;
int pos = get(mid, t);
// cout << t << " " << mid << " " << pos << endl;
if(pos >= limit){
s = mid + 1;
ans = mid;
}else{
e = mid - 1;
}
}
return ans + 1;
};
while(q--){
int t, l, r;
cin >> t >> l >> r;
if(t <= l){
cout << (t == l) << endl;
}else{
cout << bin_sex(l, t) - bin_sex(r + 1, t) << endl;
}
}
return 0;
}
컴파일 시 표준 에러 (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... |