提交时间:2023-11-25 11:18:59

运行 ID: 112265

#include<bits/stdc++.h> using namespace std; int b[201][10]; int main(){ int n; cin >> n; for(int i= 1;i <= n;i++){ scanf("%d",&b[i][1]); b[i][2] = 1; b[i][3] = 0; } int l,k; for(int i = n-1;i >= 1;i--){ l = 0; k = 0; for(int j = i+1;j <= n;j++){ if(b[j][1] > b[i][1] && b[j][2] > l) { l = b[j][2]; k = j; } if(l > 0){ b[i][2] = l+1; b[i][3] = k; } } } k = 1; for(int j = 1;j <= n;j++){ if(b[j][2] > b[k][2]){ k = j; } } cout << n-b[k][2] << endl; return 0; }