提交时间:2024-04-03 13:35:41
运行 ID: 141308
#include<bits/stdc++.h> using namespace std; int b[1010][1010]; int main(){ int n; cin >> n; for(int i =1;i<= n;i++){ cin >> 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 << b[k][2] << endl; return 0; }