求查错
查看原帖
求查错
39993
元夕楼主2020/11/24 18:24
/*******************************************
*Author       :  ExJack 
*Created Time :  2020.11.24.16:31
*Problem      :  p2827
*Mail         :  724033213@qq.com 
*******************************************/
#include <bits/stdc++.h>
#define ll long long
const int maxn = 7e6 + 5;
using namespace std;
inline int read(){
	char c; int x = 0;int b = 1; do {c = getchar(); if(c == 45) b = -1;} while(c > 57 || c < 48);
	do x = x*10 + c - 48, c = getchar(); while(c <= 57 && c >= 48); x *= b; return x;
}
int n, m, q, u, v, t, a[maxn], b[maxn], c[maxn], rnd;
int head[3], tail[3];
double p; 
void getfront(int &top) {
	top = 0;
	if(head[0] > tail[0]) {
		if(b[head[1]] < c[head[2]]) {
			top = c[head[2] ++];
		} else {
			top = b[head[1] ++];
		}
	} else {
		if(a[head[0]] >= b[head[1]] && a[head[0]] >= c[head[2]]) 
			top = a[head[0] ++];
		else if(a[head[0]] <= b[head[1]] && a[head[0]] >= c[head[2]]) 
			top = b[head[1] ++];
		else if(a[head[0]] <= b[head[1]] && b[head[1]] <= c[head[2]]) 
			top = c[head[2] ++];
	} 
}
bool cmp(int a, int b) {return a > b;}
priority_queue <int> pq;
int main() {
	freopen("p2827.in", "r", stdin);
	freopen("p2827.out", "w", stdout);
	//cerr << 1.0*clock()/CLOCKS_PER_SEC << endl;
	n = read(), m = read(), q = read(), u = read(), v = read(), t = read();
	p = 1.0 * u / v;
	for(int i = 1; i <= n; i ++) a[i] = read();
	head[0] = head[1] = head[2] = 1;
	tail[0] = n; tail[1] = tail[2] = 0;
	sort(a + 1, a + 1 + n, cmp);
	for(int i = 1, top; i <= m; i ++) {
		getfront(top);
//		cout << top << " <-\n"; 		
		top += rnd;
		int div1 = floor(1.0 * (double)top * p);
		int div2 = top - div1;
		rnd += q;
		div1 -= rnd; div2 -= rnd;
		b[++ tail[1]] = div1, c[++ tail[2]] = div2;
		if(i % t == 0) printf("%d ", top);
	}
	puts("");
	for(int i = head[0]; i <= tail[0]; i ++) pq.push(a[i]);
	for(int i = head[1]; i <= tail[1]; i ++) pq.push(b[i]);
	for(int i = head[2]; i <= tail[2]; i ++) pq.push(c[i]);
//	cout << head[0] << " " << tail[0] << "\n";
//	cout << head[1] << " " << tail[1] << "\n";
//	cout << head[2] << " " << tail[2] << "\n";
	for(int i = 1; pq.size(); i ++) {
		if(i % t == 0)
			printf("%d ", pq.top() + rnd);
		pq.pop();
	}
	return 0;
}

2020/11/24 18:24
加载中...