提交时间:2024-03-30 17:32:09
运行 ID: 140716
# 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 ++ ; } a [n + 1] = 114514 ; for ( int i = 1 ; i <= n + 1 ; i ++ ) { if ( a [i] <= a [i - 1] ) { dp [i] = dp [i - 1] + 1 ; } else { dp [i] = 1 ; 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 [++ m] = a [i] ; } else { g [k] = a [i] ; } } cout << maxn << ' ' << m << endl ; }