Submission #82980

# Submission time Handle Problem Language Result Execution time Memory
82980 2018-11-03T12:42:41 Z Bodo171 Worst Reporter 3 (JOI18_worst_reporter3) C++14
12 / 100
2000 ms 15124 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(int x,int t)
{
    int ret=0;
    int 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;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2039 ms 15124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 15124 KB Output is correct
2 Correct 5 ms 15124 KB Output is correct
3 Correct 4 ms 15124 KB Output is correct
4 Correct 4 ms 15124 KB Output is correct
5 Correct 4 ms 15124 KB Output is correct
6 Correct 5 ms 15124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2039 ms 15124 KB Time limit exceeded
2 Halted 0 ms 0 KB -