제출 #1168177

#제출 시각아이디문제언어결과실행 시간메모리
1168177stdfloatBoat (APIO16_boat)C++20
9 / 100
2095 ms589824 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int md = (int)1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; i++) cin >> a[i] >> b[i]; vector<vector<int>> dp(n); for (int i = 0; i < n; i++) dp[i].assign(b[i] - a[i] + 2, !i); for (int i = 1; i < n; i++) { for (auto j : dp[i - 1]) dp[i][0] = (dp[i][0] + j) % md; for (int j = a[i]; j <= b[i]; j++) { dp[i][j - a[i] + 1] = 1; for (int z = 0; z < i; z++) { for (int k = a[z]; k <= min(j - 1, b[z]); k++) dp[i][j - a[i] + 1] = (dp[i][j - a[i] + 1] + dp[z][k - a[z] + 1]) % md; } } } int ans = -1; for (auto i : dp[n - 1]) ans = (ans + i) % md; cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...