Submission #1111470

#TimeUsernameProblemLanguageResultExecution timeMemory
1111470justin271828Trains (BOI24_trains)C++14
0 / 100
20 ms2640 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; for (int i = 0; i < N; i++) { diff[i+1]++; diff[i+1+x[i]]--; } 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...