#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[300005],dp[300005],suff[300005];
// bool kondisi[300005];
ll mod=1000000007;
int main(){
a[0]=1e9;
cin>>n;
for (int i=1;i<=n;i++){
cin>>a[i];
}
dp[0]=1;
for (int i=1;i<=n;i++){
for (int j=0;j<i;j++){
ll u=min(a[j],a[i]);
ll kondisi=0;
for (int k=j+1;k<i;k++){
if (a[k]<u) kondisi=1;
}
if (kondisi==0) {
dp[i]+=dp[j];
dp[i]=dp[i]%mod;
}
}
}
suff[n]=a[n];
for (int i=n-1;i>=1;i--){
suff[i]=min(suff[i+1],a[i]);
}
ll ans=0;
for (int i=1;i<=n;i++){
if (suff[i]==a[i]) ans+=dp[i];
ans=ans%mod;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |