Submission #1047443

#TimeUsernameProblemLanguageResultExecution timeMemory
1047443LucaIlieTrains (BOI24_trains)C++17
21 / 100
2096 ms2644 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5; const int MOD = 1e9 + 7; int d[MAX_N + 1], x[MAX_N + 1], dp[MAX_N + 1]; int main() { int n; cin >> n; for ( int i = 1; i <= n; i++ ) cin >> d[i] >> x[i]; dp[1] = 1; for ( int i = 1; i <= n; i++ ) { if ( d[i] == 0 ) continue; for ( int j = i + d[i]; j <= n && j <= i + (long long)x[i] * d[i]; j += d[i] ) dp[j] = (dp[j] + dp[i]) % MOD; } int ans = 0; for ( int i = 1; i <= n; i++ ) ans = (ans + dp[i]) % MOD; cout << ans; 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...