Submission #285025

#TimeUsernameProblemLanguageResultExecution timeMemory
285025leductoanWorst Reporter 3 (JOI18_worst_reporter3)C++14
12 / 100
599 ms11512 KiB
#include<bits/stdc++.h> using namespace std; #define task "reporter3" #define lb lower_bound #define ub upper_bound #define ALL(v) (v).begin(),(v).end() #define zs(v) ll((v).size()) #define fi first #define se second #define pb push_back #define mp make_pair #define rep(i,a,b) for(ll i=(a),_b=(b);i<=_b;++i) #define per(i,b,a) for(ll i=(b),_a=(a);i>=_a;--i) #define rep_(i,a,b) for(ll i=(a),_b=(b);i<_b;++i) typedef long double ld; typedef long long ll; typedef pair<ll,ll> pii; const ll d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1}; const ll d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1}; const ll mod=1000000007; /// 998244353 const ll base=311; const ll N=5e5+5; ll n,q,a[N]; ll b[N]; void biot() { cin>>n>>q; for(ll i=1;i<=n;++i) cin>>a[i]; b[0]=1; for(ll i=1;i<=n;++i) { b[i]=((a[i]+b[i-1]-1)/b[i-1])*b[i-1]; // cout<<b[i]<<' '; } // cout<<endl; while(q--) { ll L,R,t; cin>>t>>L>>R; ll l=0, r=n; ll ansl=-1, ansr=-1; while(l<=r) { ll mid=(l+r)>>1; if((t/b[mid])*b[mid]-mid>=L) l=mid+1, ansl=mid; else r=mid-1; } l=0, r=n; while(l<=r) { ll mid=(l+r)>>1; if(t/b[mid]*b[mid]-mid<=R) r=mid-1, ansr=mid; else l=mid+1; } cout<<ansl-ansr+1<<'\n'; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } biot(); }

Compilation message (stderr)

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   65 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   66 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...