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>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,f[1000009],dp[1000009],g[1000009];
map <int, int> m;
map <int, int>::iterator it;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a;
for(i=1; i<=a; i++) cin>>f[i];
dp[0]=0;
for(i=1; i<=a; i++){
dp[i]=i;
for(j=i-1; j>=0; j--){
for(jj=j; jj>=1; jj--){
if(f[jj]>f[j+1]&&f[jj]<f[i]) break;
}
if(jj==0){
dp[i]=min(dp[i],dp[j]+1);
}
if(f[j]>f[j+1]) break;
}
}
cout<<dp[a];
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... |