Submission #1066419

#TimeUsernameProblemLanguageResultExecution timeMemory
1066419Essa2006Trains (BOI24_trains)C++14
0 / 100
2047 ms2384 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n; cin >> n; vector<int> D(n), X(n); vector<ll> dp(n); ll sum = 0; for (int i = 0; i < n; i++) { cin >> D[i] >> X[i]; if (i == 0) { dp[i] = 1; sum += dp[i]; continue; } for (int j = 0; j < i; j++) { if (i <= j + D[j] * X[j] && D[j] && ((i - j) % D[j] == 0)) { dp[i] += dp[j]; dp[i] %= mod; } } //cout << i + 1 << " : " << dp[i] << endl; sum += dp[i]; sum %= mod; } cout << sum; }
#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...