提交时间:2023-11-25 11:06:48
运行 ID: 112243
#include<bits/stdc++.h> using namespace std; int b[201][10]; int main(){ int n=1; while(~scanf("%d",&b[n][1])){ b[n][2] = 1; b[n][3] = 0; n++; } 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 << "max=" << b[k][2] << endl; while(k!=0){ cout<< b[k][1] << ' ' ; k = b[k][3]; } return 0; }