提交时间:2024-03-31 21:44:24
运行 ID: 140857
# include <bits/stdc++.h> using namespace std ; int n = 1 , m , x [100001] , dp [100001] , g [5005] ; int main ( ) { while ( cin >> x [n] ) { n ++ ; } n -- ; dp [1] = 1 ; for ( int i = 2 ; i <= n ; i++) { dp [i] = 1 ; for ( int j = 1 ; j <= i ; j ++ ) { if ( x [j] >= x [i] ) { dp [i] = max ( dp [i] , dp [j] + 1 ) ; } } cout << dp [i] << ' ' ; } cout << endl ; cout << dp [n] << ' ' ; for ( int i = 1 ; i <= n ; i ++ ) { int k = 1 ; while ( k <= m && g [k] < x [i] ) { k ++ ; } if ( k > m ) { g [++ m] = x [i] ; } else { g [k] = x [i] ; } } cout << m << endl ; return 0 ; }