提交时间:2024-01-20 20:36:59
运行 ID: 120666
# include <bits/stdc++.h> using namespace std ; queue <int> nums ; int mx ( queue <int> x ) { int mxn = 0 ; while ( ! x . empty ( ) ) { mxn = max ( mxn , x . front ( ) ) ; x . pop ( ) ; } return mxn ; } string i2s ( int x ) { string ans = "" ; while ( x != 0 ) { ans = ans + char ( ( x % 10 ) + '0' ) ; x /= 10 ; } return ans ; } int main ( ) { int n , m ; string ans = "" ; cin >> n >> m ; for ( int i = 1 ; i <= n ; i ++ ) { int x ; cin >> x ; if ( i > m ) { ans += i2s ( mx ( nums ) ) ; nums . pop ( ) ; } nums . push ( x ) ; } ans += i2s ( mx ( nums ) ) ; cout << ans << endl ; return 0 ; }