Submission #1015086

#TimeUsernameProblemLanguageResultExecution timeMemory
1015086vjudge1Boat (APIO16_boat)C++17
31 / 100
1110 ms524288 KiB
#include<bits/stdc++.h> using namespace std; const int mod = 1'000'000'007; int main() { int n; cin >> n; int a[1 + n], b[1 + n]; // [a[i], a[i] + b[i]) a[0] = 0, b[0] = 1; for(int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; b[i] = b[i] - a[i] + 1; } vector<vector<int> > dp(1 + n); dp[0].push_back(1); for(int i = 1; i <= n; i++) { dp[i].resize(b[i]); for(int j = 0; j < b[i]; j++) { int x = a[i] + j; for(int k = 0; k < i; k++) { int len = min(b[k], max(0, x - a[k])); if(len > 0) dp[i][j] += dp[k][len - 1]; dp[i][j] %= mod; } } for(int j = 1; j < b[i]; j++) dp[i][j] += dp[i][j - 1], dp[i][j] %= mod; } int ans = 0; for(int i = 1; i <= n; i ++) ans += dp[i].back(), 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...