Submission #937069

#TimeUsernameProblemLanguageResultExecution timeMemory
937069groshiWorst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
435 ms30248 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int t[600000]; int suma[600000]; int n; int licz(int kiedy,int x) { int pocz=0,kon=n,sre; while(pocz<=kon) { sre=(pocz+kon)/2; if(kiedy/suma[sre]*suma[sre]-sre>=x) pocz=sre+1; else kon=sre-1; } return kon+1; } int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int zap,tt,l,r; cin>>n>>zap; for(int i=1;i<=n;i++) cin>>t[i]; suma[0]=1; for(int i=1;i<=n;i++) { suma[i]=max(t[i],suma[i-1]); suma[i]=suma[i-1]*((suma[i-1]+suma[i]-1)/suma[i-1]); } while(zap--) { cin>>tt>>l>>r; cout<<licz(tt,l)-licz(tt,r+1)<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...