Submission #654235

#TimeUsernameProblemLanguageResultExecution timeMemory
654235HanksburgerWorst Reporter 3 (JOI18_worst_reporter3)C++17
100 / 100
1705 ms8208 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() { 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...