蒟蒻零分求助
查看原帖
蒟蒻零分求助
950927
_luo_gu楼主2023/8/23 09:57
#include <bits/stdc++.h>
using namespace std ;
struct stx{
	int x ;//重量 
	int i ;//下标 
};
int n , a , x ,ma_t , macnt;
stx ma[201010]  ;
int main(){
	cin >> n ;
	int cnt = 0 ;
	for( int i = 1 ; i <= n ; i ++ ){
		cin >> a ;
		if( a == 0 ){
			cnt ++ ;
			cin >> x ;
			while( ma[ma_t-1].x < x && ma_t > 0  ){
				ma_t -- ;
			}
			ma[ma_t].x = x ;
			ma[ma_t].i = i ;
			ma_t ++ ;
		}
		if( a == 1 ){
			int m = 0 ;
			for( int j = 1 ; j <= ma_t ; j ++ ){
				if( ma[j].i > m ){
					m = ma[j].i;
				}
			}
			int markk = false ;
			for( int j = 1 ; j <= ma_t ; j ++ ){
				if( markk == true ){
					ma[j-1] = ma[j] ;
					if( j == ma_t ){
						ma[j].x = 0 ;
						ma[j].i = 0 ;
					}
				}
				if( j == m ){
					markk = true ;
				}
			}
		}
		if( a == 2 ){
			cout <<ma[1].x << endl;
		}
	}
	return 0 ;
}

感谢大佬!好人一生平安!

2023/8/23 09:57
加载中...