제출 #1033259

#제출 시각아이디문제언어결과실행 시간메모리
1033259borisAngelovTrains (BOI24_trains)C++17
21 / 100
2041 ms1512 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; const int mod = 1e9 + 7; int n; int d[maxn], x[maxn]; int dp[maxn]; void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); cin >> n; for (int i = 1; i <= n; ++i) { cin >> d[i] >> x[i]; } dp[1] = 1; int ans = 1; for (int i = 2; i <= n; ++i) { for (int j = i - 1; j >= 1; --j) { if (d[j] != 0 && (i - j) % d[j] == 0 && (i - j) / d[j] <= x[j]) { dp[i] += dp[j]; if (dp[i] >= mod) dp[i] -= mod; } } ans += dp[i]; if (ans >= mod) ans -= mod; } cout << ans << endl; 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...