【求助各路大犇】35pts求助!!!
查看原帖
【求助各路大犇】35pts求助!!!
376970
fishPJ楼主2023/8/11 22:50

如题,35pts WA,急,在线等!!!

#include<bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define int long long
#define RD read()
using namespace std;
inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	while(!isdigit(ch)) {if(ch == '-') f = -1; ch = getchar();}
	while(isdigit(ch)) {x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int const N = 7e6 + 5, inf = 2e18;
int a[N];
int n, m, q, t, s;
double p;
int u, v;
int h0, h1, h2, t0, t1, t2;
int now[N], cut2[N], cut1[N];
priority_queue<int> ans;
bool cmp(int a, int b) {
	return a > b;
}
signed main() {
	n = RD, m = RD, q = RD;
	cin >> u >> v;			
	p = (double) u / v, t = RD;
	h0 = h1 = h2 = 1;
	for(t0 = 1; t0 <= n; t0++) now[t0] = RD; --t0;
	sort(now + 1, now + 1 + t0, cmp);
	int x;
	rep(i, 1, m) {
		if(h0 > t0) {
			if(cut1[h1] > cut2[h2]) x = cut1[h1++];
			else x = cut2[h2++];
		}
		else if(now[h0] >= cut1[h1] && now[h0] >= cut2[h2]) x = now[h0++];
		else if(cut1[h1] >= cut2[h2] && now[h0] <= cut1[h2]) x = cut1[h1++];
		else x = cut2[h2++];
		x += s;
		int x1 = floor(p * (double) x), x2 = x - x1;
		s += q;
		cut1[++t1] = x1 - s;
		cut2[++t2] = x2 - s;
		if(i % t == 0) printf("%lld ", x);
	}puts("");
	rep(i, h0, t0) ans.push(now[i]);
	rep(i, h1, t1) ans.push(cut1[i]);
	rep(i, h2, t2) ans.push(cut2[i]);
	int i = 1;
	while(!ans.empty()) {
		if(i % t == 0) printf("%lld ", ans.top() + s);
		i ++; ans.pop();
	}
	return 0;
}
2023/8/11 22:50
加载中...