Submission #654234

#TimeUsernameProblemLanguageResultExecution timeMemory
654234HanksburgerWorst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
653 ms25300 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int a[500005], n, q; int f(int t, int x) { int l=0, r=n+1; while (l<r) { int m=(l+r)/2; if (t/a[m]*a[m]-m<=x) r=m; else l=m+1; } return n-r+2; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> q; a[0]=1; for (int i=1; i<=n; i++) { cin >> a[i]; a[i]=((a[i]-1)/a[i-1]+1)*a[i-1]; } for (int i=1; i<=q; i++) { int t, l, r; cin >> t >> l >> r; cout << f(t, r)-f(t, l-1) << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...