답안 #82979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
82979 2018-11-03T12:39:23 Z Bodo171 Worst Reporter 3 (JOI18_worst_reporter3) C++14
0 / 100
2000 ms 15144 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;
int calc(long long x,long long t)
{
    int ret=0;
    long long vv;
    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]));
                if(!d[i]%val[i-1])
                    val[i]=d[i];
            }
            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 2061 ms 15144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 15144 KB Output is correct
2 Correct 4 ms 15144 KB Output is correct
3 Correct 4 ms 15144 KB Output is correct
4 Correct 4 ms 15144 KB Output is correct
5 Incorrect 5 ms 15144 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2061 ms 15144 KB Time limit exceeded
2 Halted 0 ms 0 KB -