This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define sz size()
#define ll long long
const int N = 5e2 + 5;
ll a[N], n, md = 1e9 + 7, dp[N][2];
int main () {
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
int l, r;
cin >> l >> r;
a[i] = l;
}
for (int i = 1; i <= n; ++i) {
dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
dp[i][0] %= md;
dp[i][1] = 1;
for (int j = i - 1; j > 0; j--) {
if (a[i] > a[j]) {
dp[i][1] += dp[j][1];
dp[i][1] %= md;
}
}
}
cout << (dp[n][1] + dp[n][0]) % md;
}
# | 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... |