답안 #1088986

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088986 2024-09-15T17:22:16 Z DobromirAngelov Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
345 ms 23492 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

const int MAXN=5e5+5;
const int MAXQ=5e5+5;

int n,q;
unsigned int v[MAXN];

int getPos(int ind,int t)
{
    return (t/v[ind])*v[ind]-ind;
}

int bs(int x,int t)
{
    int l=0,r=n;
    while(l<r)
    {
        int mid=(l+r+1)/2;
        if(getPos(mid,t)>=x) l=mid;
        else r=mid-1;
    }
    return l;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>v[i];

    for(int i=2;i<=n;i++)
    {
        v[i]=((v[i]+v[i-1]-1)/v[i-1])*v[i-1];
    }

    for(int i=0;i<q;i++)
    {
        int t,l,r;
        cin>>t>>l>>r;

        int ind1=bs(r+1,t);
        int ind2=bs(l,t);
        int ans=0;
        if(l<=t && t<=r) ans++;
        ans+=ind2-ind1;
        cout<<ans<<endl;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 326 ms 17496 KB Output is correct
2 Correct 345 ms 17684 KB Output is correct
3 Correct 344 ms 17488 KB Output is correct
4 Correct 327 ms 17488 KB Output is correct
5 Correct 335 ms 17236 KB Output is correct
6 Correct 334 ms 17232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 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 326 ms 17496 KB Output is correct
2 Correct 345 ms 17684 KB Output is correct
3 Correct 344 ms 17488 KB Output is correct
4 Correct 327 ms 17488 KB Output is correct
5 Correct 335 ms 17236 KB Output is correct
6 Correct 334 ms 17232 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 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 196 ms 15432 KB Output is correct
14 Correct 202 ms 19792 KB Output is correct
15 Correct 199 ms 18572 KB Output is correct
16 Correct 201 ms 19028 KB Output is correct
17 Correct 253 ms 23436 KB Output is correct
18 Correct 264 ms 23380 KB Output is correct
19 Correct 258 ms 23492 KB Output is correct
20 Correct 273 ms 23376 KB Output is correct
21 Correct 255 ms 23324 KB Output is correct
22 Correct 255 ms 23344 KB Output is correct
23 Correct 263 ms 23232 KB Output is correct
24 Correct 254 ms 23380 KB Output is correct
25 Correct 333 ms 20692 KB Output is correct
26 Correct 334 ms 20692 KB Output is correct
27 Correct 275 ms 22860 KB Output is correct
28 Correct 263 ms 23116 KB Output is correct
29 Correct 275 ms 22628 KB Output is correct
30 Correct 290 ms 22868 KB Output is correct
31 Correct 283 ms 23120 KB Output is correct
32 Correct 267 ms 19392 KB Output is correct
33 Correct 0 ms 344 KB Output is correct