Submission #1111502

#TimeUsernameProblemLanguageResultExecution timeMemory
1111502justin271828Trains (BOI24_trains)C++14
0 / 100
22 ms1864 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; if (N == 1) { cout << 1; return 0; } long long d[N]; long long x[N]; for (long long i = 0; i < N; i++) { cin >> d[i] >> x[i]; } long long diff[N]; memset(diff, 0, sizeof(diff)); diff[0] = 1; diff[1] = -1; long long dsum = 0; for (int i = 0; i < N-1; i++) { dsum += diff[i]; dsum %= 1000000007; diff[i+1] += dsum; diff[i+1] %= 1000000007; if (i+1+x[i] < N) { diff[i+1+x[i]] -= dsum; diff[i+1+x[i]]%=1000000007; } } long long sum[N]; sum[0] = 1; for (int i = 1; i < N; i++) { sum[i] = sum[i-1]+diff[i]; sum[i]%=1000000007; } long long ans = 0; for (long long i: sum) { ans += i; ans %= 1000000007; } 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...