이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int n;
ll x;
vector<ll> v;
vector<pair<ll, int> > ycoords;
int indexes[501];
ll dp[501][501];
ll getDP(int a, int b) {
if (a == -1)
{
return 1;
}
if (dp[a][b] > 0)
{
return dp[a][b];
}
ll ans = 0;
if (ycoords[b].first >= v[a])
{
ans += getDP(a-1, indexes[a]);
ans %= mod;
}
ans += getDP(a-1, b);
ans %= mod;
dp[a][b] = ans;
return ans;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> x >> x;
v.push_back(x);
ycoords.push_back({x, i});
}
sort(ycoords.begin(), ycoords.end());
for (int i = 0; i < n; i++)
{
indexes[ycoords[i].second] = i;
}
ll ans = getDP(n-1, n-1) - 1;
ans %= mod;
cout << ans << "\n";
}
# | 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... |