30pts其他全RE求助
查看原帖
30pts其他全RE求助
576378
creation_hy楼主2022/10/7 20:30
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const int MAXN = 1e5 + 5;
ll n, m, q, t, x, tim = 1, a[MAXN];
double p;
queue<pll> q1, q2, q3;
pll tmp;
inline ll realLen(pll x)
{
    return x.first + (tim - x.second) * q;
}
bool cmp(ll x, ll y)
{
    return x > y;
}
inline void getMax()
{
    ll l1 = -4e18, l2 = -4e18, l3 = -4e18;
    if (!q1.empty())
        l1 = realLen(q1.front());
    if (!q2.empty())
        l2 = realLen(q2.front());
    if (!q3.empty())
        l3 = realLen(q3.front());
    if (l3 > l1 && l3 > l2)
    {
        tmp.first = l3;
        q3.pop();
    }
    else if (l1 > l2 && l1 > l3)
    {
        tmp.first = l1;
        q1.pop();
    }
    else
    {
        tmp.first = l2;
        q2.pop();
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // freopen("tmp.in", "r", stdin);
    double u, v;
    cin >> n >> m >> q >> u >> v >> t;
    p = u / v;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + 1 + n, cmp);
    for (int i = 1; i <= n; i++)
        q3.emplace(make_pair(a[i], 1));
    while (tim <= m)
    {
        getMax();
        if (!(tim % t))
            cout << tmp.first << ' ';
        tim++;
        q1.emplace(make_pair((ll)floor(tmp.first * p), tim));
        q2.emplace(make_pair(tmp.first - (ll)floor(tmp.first * p), tim));
    }
    cout << '\n';
    for (int i = 1; i <= n + m; i++)
    {
        getMax();
        if (!(i % t))
            cout << tmp.first << ' ';
    }
    // fclose(stdin);
    return 0;
}
2022/10/7 20:30
加载中...