Submission #437956

#TimeUsernameProblemLanguageResultExecution timeMemory
437956blueWorst Reporter 3 (JOI18_worst_reporter3)C++17
12 / 100
2054 ms25124 KiB
#include <iostream> using namespace std; /* Let P(i, t) be the position of the person i at the time t P(0, t) = t P(1, t) = -1 + P(0, t) Every contestant i jumps J[i] units to the right every T[i] seconds. */ const int maxN = 500000; int N, Q; int D[1+maxN]; long long JT[1+maxN]; //jump time long long J[1+maxN]; //jump distance long long loc(int i, long long t) { return J[i] * (t/JT[i]) - i; } int main() { int N, Q; cin >> N >> Q; for(int i = 1; i <= N; i++) cin >> D[i]; JT[0] = 1; J[0] = 1; for(int i = 1; i <= N; i++) { JT[i] = min(((D[i] / J[i-1]) + bool(D[i] % J[i-1])) * JT[i-1], 1'000'000'001LL); J[i] = J[i-1]*(JT[i] / JT[i-1]); // cerr << "JT[" << i << "] = " << JT[i] << ", J[" << i << "] = " << J[i] << '\n'; } for(int j = 1; j <= Q; j++) { long long T, L, R; cin >> T >> L >> R; // for(int i = 0; i <= N; i++) cerr << loc(i, T) << ' '; // cerr << '\n'; int rm = -1; for(int bit = 20; bit >= 0; bit--) { int p = rm + (1 << bit); if(p > N) continue; if(loc(p, T) <= R) continue; rm = p; } rm++; if(rm > N || loc(rm, T) < L || R < loc(rm, T)) { cout << 0 << '\n'; continue; } int lm = -1; for(int bit = 20; bit >= 0; bit--) { int p = lm + (1 << bit); if(p > N) continue; if(L <= loc(p, T)) lm = p; } cout << lm-rm+1 << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...