Submission #1033549

#TimeUsernameProblemLanguageResultExecution timeMemory
1033549sp69tTrains (BOI24_trains)C++14
21 / 100
2097 ms2908 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 <= min(x_i, (n / d_i) + 2); ++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...