제출 #1118572

#제출 시각아이디문제언어결과실행 시간메모리
1118572dynam1cTrains (BOI24_trains)C++17
16 / 100
52 ms4920 KiB
#include <bits/stdc++.h> using namespace std; int mod = 1e9+7; int main() { int n; cin >> n; vector<vector<int>> ends(n+1); vector<int> ans(n); ans[0] = 1; for (int i = 0; i < n; i++) { int d, x; cin >> d >> x; int r = min(x+i, n); ends[r].push_back(i); } int cur = 0; for (int i = 0; i < n; i++) { if (i > 0) ans[i] = cur; cur = (cur + ans[i]) % mod; for (auto j : ends[i]) cur = (cur - ans[j] + mod) % mod; } cout << accumulate(ans.begin(), ans.end(), 0LL) % mod << endl; }
#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...