이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1E9 + 7;
int main() {
int n;
cin >> n;
vector<vector<long long>> pre_dp;
long long boat[n][2];
for (int i = 0; i < n; ++i) {
cin >> boat[i][0] >> boat[i][1];
pre_dp.push_back(vector<long long>(boat[i][1] - boat[i][0] + 1, 1));
}
long long answer = 0;
for (int i = 0; i < n; ++i) {
int sz = pre_dp[i].size();
for (int j = 0; j < sz; ++j) {
for (int k = 0; k < i; ++k) {
if (boat[i][0] + j > boat[k][1]) {
pre_dp[i][j] += pre_dp[k][boat[k][1] - boat[k][0]];
}
else if (boat[i][0] + j <= boat[k][0]) {
// do nothing
}
else {
pre_dp[i][j] += pre_dp[k][boat[i][0] + j - boat[k][0] - 1];
}
}
answer += pre_dp[i][j];
if (j) pre_dp[i][j] += pre_dp[i][j - 1];
pre_dp[i][j] %= mod;
}
answer %= mod;
}
answer %= mod;
cout << answer << '\n';
return 0;
}
/*
int main() {
int n;
cin >> n;
long long boat[n][2];
for (int i = 0; i < n; ++i) {
cin >> boat[i][0] >> boat[i][1];
}
long long dp[n], answer = 0;
for (int i = 0; i < n; ++i) {
dp[i] = 1;
for (int j = 0; j < i; ++j) {
if (boat[j][0] < boat[i][0]) {
dp[i] += dp[j];
}
}
dp[i] %= mod;
answer += dp[i];
}
answer %= mod;
cout << answer << '\n';
return 0;
}
*/
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |