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 int long long
#define F first
#define S second
#define pb push_back
#define B begin()
#define E end()
using namespace std;
int n;
int a[1001000];
int dp[505][505];
const int mod=1e9+7;
int f(int i,int last)
{
if(dp[i][last]!=-1)
return dp[i][last]%mod;
if(i==n+1)
return 1;
int g=f(i+1,last);
if(a[i]>a[last])
g+=f(i+1,i);
return dp[i][last]=g%mod;
}
signed main()
{
memset(dp,-1,sizeof dp);
cin>>n;
for(int i=1;i<=n;i++){
//a[i]=n-i;
cin>>a[i]>>a[i];
}
cout<<f(1,0)-1<<endl;
}
# | 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... |