提交时间:2024-03-30 17:33:14
运行 ID: 140717
# include <bits/stdc++.h> using namespace std ; int a [5005] = { 114514 } , dp [5005] , g [5005] ; int main ( ) { int n = 1 , maxn = -1 , m = 0 ; while ( cin >> a [n] ) { n ++ ; } for ( int i = 1 ; i <= n ; i ++ ) { if ( a [i] <= a [i - 1] ) { dp [i] = dp [i - 1] + 1 ; } else { dp [i] = 1 ; maxn = max ( maxn , dp [i - 1] ) ; } } maxn = max ( maxn , dp [n] ) ; for ( int i = 1 ; i <= n ; i ++ ) { int k = 1 ; while ( k <= m && g [k] < a [i] ) { k ++ ; } if ( k > m ) { g [++ m] = a [i] ; } else { g [k] = a [i] ; } } cout << maxn << ' ' << m << endl ; }