Submission #835531

#TimeUsernameProblemLanguageResultExecution timeMemory
835531fdnfksdWorst Reporter 3 (JOI18_worst_reporter3)C++14
12 / 100
11 ms4016 KiB
#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 (stderr)

worst_reporter3.cpp: In function 'void solve()':
worst_reporter3.cpp:46:16: warning: unused variable 'x' [-Wunused-variable]
   46 |             ll x=jump[cur];
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...