Submission #1051451

#TimeUsernameProblemLanguageResultExecution timeMemory
1051451pravcoderTrains (BOI24_trains)C++14
21 / 100
2074 ms2396 KiB
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <string> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> v2i; typedef pair<int, int> pi; typedef vector<ll> vl; #define pb push_back #define mp make_pair #define rep(i, n) for (int i = 0; i < n; i++) const ll p = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, di, xi; vl d, x; cin >> n; rep(i, n) { cin >> di >> xi; d.pb(di); x.pb(xi); } vl dp = { 1 }; ll total = 1; for (int i = 1; i < n; i++) { ll t = 0; for (int j = 0; j < i; j++) { if (d[j] != 0) { if ((i-j) % d[j] == 0 && i-j <= d[j] * x[j]) { t += dp[j]; t %= p; //cout << i << " can be reached by " << j << "\n"; } } } dp.pb(t); total += t; total %= p; //cout << "calculated " << i << " as " << t << "\n"; } cout << total; 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...