답안 #835531

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835531 2023-08-23T15:31:58 Z fdnfksd Worst Reporter 3 (JOI18_worst_reporter3) C++14
12 / 100
11 ms 4016 KB
#include<bits/stdc++.h>
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e18;
const ll mod=1e9+7;
ll get(ll i,ll j,ll l,ll r)
{
    return max(min(j,r)-max(i,l)+1,0ll);
}
ll n,q,jump[maxN],d[maxN],nxt[maxN],m[maxN];
void solve()
{
    cin >> n >> q;
    for(int i=1;i<=n;i++) cin >> d[i],jump[i]=d[i];
    for(int i=2;i<=n;i++)
    {
        ll x=jump[i-1];
        ll y=(d[i]+x-1)/x*x;
        jump[i]=y;
        m[i]=jump[i]/jump[i-1];
    }
    nxt[n]=n;
    for(int i=n-1;i>=1;i--)
    {
        nxt[i]=nxt[i+1];
        if(jump[i]!=jump[i+1]) nxt[i]=i;
    }
    for(int i=1;i<=q;i++)
    {
        ll l,r,t;

        cin >> t >> l >> r;
        ll luot=t/d[1];
        ll vd=luot*d[1]-1;
        ll ans=0;
        if(vd>=l&&vd<=r) ans=1;
        ll cur=2;
        while(cur<=n)
        {
            ll x=jump[cur];
            luot/=m[cur];
            ll cc=luot*jump[cur];
            ans+=get(l,r,cc-nxt[cur],cc-cur);
            cur=nxt[cur]+1;
        }
        ans+=((t>=l)&&(t<=r));
        cout << ans << '\n';
    }

}
int main()
{
    fastio
    //freopen(TASKNAME".INP","r",stdin);
    //freopen(TASKNAME".OUT","w",stdout);
    solve();
}

Compilation message

worst_reporter3.cpp: In function 'void solve()':
worst_reporter3.cpp:46:16: warning: unused variable 'x' [-Wunused-variable]
   46 |             ll x=jump[cur];
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 4016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 388 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 4016 KB Output isn't correct
2 Halted 0 ms 0 KB -