답안 #82978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82978 2018-11-03T12:35:25 Z Bodo171 Worst Reporter 3 (JOI18_worst_reporter3) C++14
0 / 100
2000 ms 30452 KB
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=500005;
long long d[nmax],fv[nmax],val[nmax];
long long l,r,t;
int n,q,p,i;
long long calc(long long x,long long t)
{
    long long ret=0,vv=0;
    if(t<x)
        return 0;
    for(int p=18;p>=0;p--)
    {
        vv=ret+(1<<p);
        if(vv<=n&&(t/fv[vv])*(val[vv])-vv>=x)
            ret+=(1<<p);
    }
    return ret+1;
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>q;
    for(i=1;i<=n;i++)
    {
        cin>>d[i];
        if(i==1) fv[i]=d[i],val[i]=d[i];
        else
        {
            if(val[i-1]<d[i])
            {
                fv[i]=(1LL*fv[i-1]*((d[i]+val[i-1]-1)/val[i-1]));
                val[i]=(d[i]+val[i-1]-(d[i]%val[i-1]));
            }
            else
            {
                fv[i]=fv[i-1];
                val[i]=val[i-1];
            }
            fv[i]=min(fv[i],1LL*(1000*1000*1000+1));
        }
    }
    for(i=1;i<=q;i++)
    {
        cin>>t>>l>>r;
        cout<<calc(l,t)-calc(r+1,t)<<'\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2058 ms 30452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 30452 KB Output is correct
2 Correct 4 ms 30452 KB Output is correct
3 Correct 4 ms 30452 KB Output is correct
4 Correct 5 ms 30452 KB Output is correct
5 Incorrect 5 ms 30452 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2058 ms 30452 KB Time limit exceeded
2 Halted 0 ms 0 KB -