提交时间:2024-03-30 17:23:41

运行 ID: 140701

# 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 ++ ; } dp [0] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( a [i] <= a [i - 1] ) { dp [i] = dp [i - 1] + 1 ; } else { maxn = max ( maxn , dp [i - 1] ) ; } } for ( int i = 1 ; i <= n ; i ++ ) { int k = 1 ; while ( k <= m && g [k] < a [i] ) { k ++ ; } if ( k > m ) { g [++ k] = a [i] ; } else { g [k] = a [i] ; } } cout << maxn << endl << m << endl ; }