Submission #644028

#TimeUsernameProblemLanguageResultExecution timeMemory
644028someoneWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
542 ms22972 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1 << 19, INF = 1e18 + 42; int n, q, period[N]; int dicho(int t, int obj) { int ans = -1; for(int i = 18; i >= 0; i--) if(period[ans + (1 << i)] * (t / period[ans + (1 << i)]) - ans - (1 << i) >= obj) ans += (1 << i); return ans; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> q; n++; period[0] = 1; for(int i = 1; i < n; i++) { cin >> period[i]; period[i] = ((period[i] + period[i-1] - 1) / period[i-1]) * period[i-1]; } for(int i = n; i < N; i++) period[i] = INF; for(int i = 0; i < q; i++) { int t, l, r; cin >> t >> l >> r; cout << dicho(t, l) - dicho(t, r+1) << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...