Submission #232574

#TimeUsernameProblemLanguageResultExecution timeMemory
232574AlexLuchianovWorst Reporter 3 (JOI18_worst_reporter3)C++14
100 / 100
635 ms23496 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <cassert> using namespace std; using ll = long long; #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) < (b)) ? (b) : (a)) int const nmax = 500000; int d[1 + nmax]; int eval(int x, int t){ return -x + t - t % d[x]; } int greaterthan(int n, int target, int t){ if(eval(0, t) < target) return 0; int x = 0; for(int jump = (1 << 20); 0 < jump; jump /= 2) if(x + jump <= n && target <= eval(x + jump, t)) x += jump; return x + 1; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, q; cin >> n >> q; d[0] = 1; for(int i = 1;i <= n; i++){ cin >> d[i]; if(d[i] <= d[i - 1]) d[i] = d[i - 1]; else d[i] = d[i - 1] * (d[i] / d[i - 1] + (0 < (d[i] % d[i - 1]))); } for(int i = 1; i <= q; i++){ int x, y, t; cin >> t >> x >> y; cout << greaterthan(n, x, t) - greaterthan(n, y + 1, t) << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...