Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
493 B
11
Indexable
Never
int findHightime(ll curT,ll l,ll d,ll k){
    curT=min(curT,l+(k-1)*d); //required time, last train
    if(curT<l) return -1; //no train before time l

    ll ind=(curT-l)/d;
    return l+ind*d;
}
/***************function 2*************************************/
auto getNextTime=[&](lli curT,const lli l,const lli d,const lli k)->lli{
        curT=min(curT,l+d*(k-1));
        if(curT<l)
            return -1;
        const lli idx = (curT-l)/d;
        return l+idx*d;
    };
Leave a Comment