답안 #855440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855440 2023-10-01T08:47:37 Z 8pete8 Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
435 ms 25560 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define int long long
const int mxn=2*1e5,mod=1000000007,lg=25,root=1000,inf=1e18;
int32_t main(){
    fastio
    int n,q;cin>>n>>q;
    vector<int>v(n+1);//jump time;
    v[0]=1;
    for(int i=1;i<=n;i++){
        int d;cin>>d;
        if(i==0){
            v[i]=d;
            continue;
        }
        int tmp=ceil(d*1.0/v[i-1]);//how many times
        v[i]=v[i-1]*tmp;
    }
    while(q--){
        int ql,qr,t;cin>>t>>ql>>qr;
        int l=0,r=n,ans1=-1,ans2=inf;
        while(l<=r){
            int mid=l+(r-l)/2;
            int val=((t/v[mid])*v[mid])-mid;
            if(val>=ql){
                l=mid+1;
                ans1=max(ans1,mid);
            }
            else r=mid-1;
        }
        l=0,r=n;
        while(l<=r){
            int mid=l+(r-l)/2;
            int val=((t/v[mid])*v[mid])-mid;
            if(val<=qr){
                r=mid-1;
                ans2=min(ans2,mid);
            }
            else l=mid+1;
        }
        if(ans2==inf)cout<<0<<'\n';
        else cout<<ans1-ans2+1<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 22612 KB Output is correct
2 Correct 423 ms 22792 KB Output is correct
3 Correct 435 ms 22820 KB Output is correct
4 Correct 428 ms 22832 KB Output is correct
5 Correct 418 ms 22676 KB Output is correct
6 Correct 432 ms 22660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 427 ms 22612 KB Output is correct
2 Correct 423 ms 22792 KB Output is correct
3 Correct 435 ms 22820 KB Output is correct
4 Correct 428 ms 22832 KB Output is correct
5 Correct 418 ms 22676 KB Output is correct
6 Correct 432 ms 22660 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 247 ms 21136 KB Output is correct
14 Correct 248 ms 21840 KB Output is correct
15 Correct 236 ms 20600 KB Output is correct
16 Correct 256 ms 20916 KB Output is correct
17 Correct 308 ms 25172 KB Output is correct
18 Correct 316 ms 25208 KB Output is correct
19 Correct 319 ms 25428 KB Output is correct
20 Correct 318 ms 25204 KB Output is correct
21 Correct 315 ms 25560 KB Output is correct
22 Correct 311 ms 25428 KB Output is correct
23 Correct 329 ms 25476 KB Output is correct
24 Correct 312 ms 25364 KB Output is correct
25 Correct 423 ms 22772 KB Output is correct
26 Correct 420 ms 22640 KB Output is correct
27 Correct 371 ms 24808 KB Output is correct
28 Correct 344 ms 25188 KB Output is correct
29 Correct 337 ms 24592 KB Output is correct
30 Correct 359 ms 24940 KB Output is correct
31 Correct 367 ms 25168 KB Output is correct
32 Correct 335 ms 21452 KB Output is correct
33 Correct 1 ms 348 KB Output is correct