求助全WA
查看原帖
求助全WA
719942
zzq_helloworld楼主2022/8/26 18:37

不知道为什么,但是调了半天。

#include <bits/stdc++.h>
using namespace std;

const int Max = 1e5 + 1;

inline int Read() {
	int x = 0;
	int f = 1;
    char c = getchar();
    for(; c < '0' || c > '9';c = getchar())
        if(c == '-')
            f = -1;
    for(;c <= '9' && c >= '0';c = getchar())
        x = (x << 3) + (x << 1) + (c ^ 48);
    return (f == 1 ? x : -x);
}

queue <int> qu[ 4 ];
int a[ Max ];
int increase;

int main() {
//	qu [ 2 ] . push ( 0 ) , qu [ 3 ] . push ( 0 );
	int n = Read() , m = Read() , q = Read() , u = Read() , v = Read() , t = Read();
    double p = u * 1.0 / v;
    for( int i = 1 ; i <= n ; i++ ) a [ i ] = Read();
    sort( a + 1 , a + 1 + n );
    for( int i = n ; i >= 1 ; i-- ) qu[ 1 ] . push ( a[ i ] );
	for( int i = 1 ; i <= m ; i++ , increase++ ) {
    	if(qu[ 1 ].empty()) qu[ 1 ] . push( 0 );
    	if(qu[ 2 ].empty()) qu[ 2 ] . push( 0 );
    	if(qu[ 3 ].empty()) qu[ 3 ] . push( 0 );
    	if( ! (m % t) ) printf( "%d " , increase + max ( max ( qu [ 1 ] . front() , qu [ 2 ] . front()) , qu[ 3 ] . front() ) );
//    	printf ("\n%d %d %d\n",qu[1].front(),qu[2].front(),qu[3].front());
		int Max = 1;
    	if( qu [ 2 ] . front() > qu [ 1 ] . front() ) Max = 2;
    	if( qu [ 3 ] . front() > qu [ Max ] . front() ) Max = 3;
    	int tmp = qu [ Max ] . front() ;
//    	printf("%d\n",Max);
    	qu[ Max ] . pop();
    	if( qu [ 2 ] . front() == 0 ) qu [ 2 ] . pop();
		if( qu [ 3 ] . front() == 0 ) qu [ 3 ] . pop();
    	qu [ 2 ] . push ( int ( p * tmp ) - 1 ) , qu [ 3 ] . push ( tmp - int ( p * tmp ) - 1 );
//    	system("pause");
	}
	while( !qu [ 1 ] . empty() && !qu [ 2 ] . empty() && !qu [ 3 ] . empty()) {
		int Max = 1;
    	if( qu [ 2 ] . front() > qu [ 1 ] . front() ) Max = 2;
    	if( qu [ 3 ] . front() > qu [ Max ] . front() ) Max = 3;
    	printf("%d\n",qu[ Max ] . front());
    	qu[ Max ] . pop();
	}
	return 0;
}
/*
 3 0 0
 4 1 2
 4 2 3
*/
/*
 3 0 1
 2
*/
2022/8/26 18:37
加载中...