/*
* @Description: To iterate is human, to recurse divine.
* @Autor: Recursion
* @Date: 2022-04-03 15:54:48
* @LastEditTime: 2022-04-03 17:31:42
*/
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e9 + 10;
const int N = 1e6;
int t[N];
int a[N],b[N];
int n;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1;i <= n;i ++)
cin >> t[i];
for(int i = 1;i <= n;i ++){
a[i] = 1;
for(int j = 1;j < i;j ++)
if(t[i] > t[j])
a[i] = max(a[i],a[j] + 1);
}
for(int i = n;i >= 1;i --){
b[i] = 1;
for(int j = n;j > i;j --)
if(t[i] > t[j])
b[i] = max(b[i],b[j] + 1);
}
int maxn = 0;
for(int i = 1;i <= n;i ++)
maxn = max(maxn,a[i] + b[i]);
cout << n - maxn + 1 << endl;
return 0;
}
P1091 [NOIP2004 提高组] 合唱队形
最新推荐文章于 2024-07-12 08:55:10 发布