제출 #1033610

#제출 시각아이디문제언어결과실행 시간메모리
1033610DuongkobeoTrains (BOI24_trains)C++17
21 / 100
2069 ms1788 KiB
#include<bits/stdc++.h> #define endl "\n" #define rs resize #define pb push_back #define gcd __gcd const int mod = 1e9 + 7; using namespace std; void solve() { int n; cin >> n; vector<int> d(n), x(n); for (int i = 0; i < n; ++i) cin >> d[i] >> x[i]; vector<int> v(n + 1, 0); v[1] = 1; for (int i = 1; i <= n; ++i) { if (d[i - 1] > 0 && x[i - 1] > 0) { int d_i = d[i - 1]; int x_i = x[i - 1]; for (int t = 1; t <= x_i; ++t) { int city = i + t * d_i; if (city <= n) v[city] = (v[city] + v[i]) % mod; else break; } } } int res = 0; for (int i = 1; i <= n; ++i) res = (res + v[i]) % mod; cout << res; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // int t; cin >> t; // while (t--) solve(); return 0; }
#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...