Submission #1111600

#TimeUsernameProblemLanguageResultExecution timeMemory
1111600itslqTrains (BOI24_trains)C++17
0 / 100
19 ms828 KiB
#include <bits/stdc++.h> using namespace std; int N; const int MAX = 1e5, MOD = 1e9 + 7; vector<int> fenwick(MAX + 5); void update(int n, int v) { for (; n <= N; n += n & -n) { fenwick[n] = (fenwick[n] + v) % MOD; } } int query(int n) { int S = 0; for (; n > 0; n -= n & -n) { S = (S + fenwick[n]) % MOD; } return S; } int main() { cin >> N; int D, X, S = 0; for (int i = 0; i < N; i++) { cin >> D >> X; const int Q = query(i); update(i + 1, Q); update(i + X + 1, -Q); } for (int i = 0; i < N; i++) { S = (S + query(i)) % MOD; } cout << S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...