95分求。
查看原帖
95分求。
238735
Qing_s楼主2020/11/11 08:57

RT

#include<bits/stdc++.h>

using namespace std ;

int read_()
	{
		int s = 0 , w = 1 ;
		char ch = getchar() ;
		while( ch == ' ' || ch == '\n' )
			ch = getchar() ;
		while( ch < '0' || ch > '9' )
		{
			if( ch == '-' )
				w = -1 ;
			ch = getchar() ;
		}
		while( ch >= '0' && ch <= '9' )
		{
			s = s * 10 + ch - '0' ;
			ch = getchar() ;
		}
		return s * w ;
	} 

priority_queue<int> q ;
priority_queue<int> p ;

int n , w , sum , lin ;
int x , noww ;

int main(){
    n = read_() ; w = read_() ;
    for( int i = 1 ; i <= n ; i++ ){
        x = read_() ;
        q.push( x ) ;
        noww = i * ( w * 0.01 ) ;
        sum = max( 1 , noww ) ;
        if( sum == lin ){
            int l = -1 * p.top() ;
            p.pop() ;
            q.push( l ) ;
            p.push( -1 * q.top() ) ;
            q.pop() ;
        }
        else{
            lin = sum ;
            p.push( -1 * q.top() ) ;
            q.pop() ;
        }
        cout << -1 * p.top() << " " ;
    }
    return 0 ;
}
2020/11/11 08:57
加载中...