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 endl "\n"
#define ll long long
using namespace std;
const ll mod = 1e9+7;
int main(){
ll n;
cin>>n;
ll arr[n];
ll brr[n];
for(int i=0; i<n; i++){
cin>>arr[i];
cin>>brr[i];
}
ll dp[n];
dp[n-1] = 1;
for(int i=n-2; i>=0; i--){
ll a = arr[i];
// cout << a << " " << 25 << endl;
ll sum = 0;
for(int j=i+1; j<n; j++){
if(arr[j]>a){
sum = (sum+dp[j])%mod;
// cout << arr[j] << " " << 30 << endl;
}
}
dp[i] = sum+1;
}
ll ans = 0;
for(int i=0; i<n; i++){
// cout << dp[i] << " ";
ans = (ans+dp[i])%mod;
ans = ans%mod;
}
// cout<<endl;
cout << ans%mod << endl;
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... |