Submission #968677

#TimeUsernameProblemLanguageResultExecution timeMemory
968677raphaelpWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
1388 ms29724 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long N, Q; cin >> N >> Q; N++; vector<long long> Tab(N); for (long long i = 1; i < N; i++) { cin >> Tab[i]; } Tab[0] = 1; vector<long long> step(N); long long cur = 1; for (long long i = 0; i < N; i++) { cur = cur * ceil((double)Tab[i] / cur); step[i] = cur; } for (long long i = 0; i < Q; i++) { long long T, L, R; cin >> T >> L >> R; long long l = 0, r = N; if (T - T % step[0] - 0 < L) l = -1; else while (l + 1 != r) { long long m = (l + r) / 2; if (T - T % step[m] - m >= L) l = m; else r = m; } long long temp = l; l = 0, r = N; if (T - T % step[0] - 0 <= R) l = -1; else while (l + 1 != r) { long long m = (l + r) / 2; if (T - T % step[m] - m > R) l = m; else r = m; } cout << temp - l << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...