提交时间:2023-12-04 13:36:13
运行 ID: 113903
# include <bits/stdc++.h> using namespace std ; int a[1001],dp[1001],pre[1001]; int prt(int x) { if ( x == 0 ) { return 0 ; } prt ( pre [x] ) ; cout << a [x] << " " ; } int main ( ) { int n , k , sid , ans ; while( scanf( "%d" , a + n + 1 ) ) { n++ ; } for ( int i = 1 ; i <= n ; i ++ ) { int l = 0 ; k = 0 ; for( int j = 1 ; j < i ; j ++ ) if ( ( a [j] < a [i] ) && l < dp [j] ) { l = dp [j] ; k = j ; } dp [i] = l + 1 ; pre [i] = k ; if ( dp [i] > ans ) { ans = dp [i] ; sid = i ; } } cout << "max=" << ans << endl ; prt ( sid ) ; return 0; }