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>
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
int dp[503][503],a[503],b[503];
int n;const int mod=1e9+7;
int d(int x,int y)
{
if(x==n)return 1;
int &u=dp[x][y];
if(u!=-1)return u;
u=0;
u+=d(x+1,y);
if(a[x]>a[y])u+=d(x+1,x);
u%=mod;
return u;
}
int main()
{
cin>>n;
memset(dp,-1,sizeof dp);
for(int i=0;i<n;i++)
{
cin>>a[i]>>a[i];
}
ll re=0;
for(int i=0;i<n;i++)
{
re+=d(i,i);
re%=mod;
}cout<<re;
}
# | 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... |