95pts求调,#4RE
查看原帖
95pts求调,#4RE
815576
Mary_Celeste楼主2023/1/19 09:23
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;

queue<long long> q1, q2, q3;
int a[100005] = {0};

inline long long Max()
{
    long long x = -2e18, y = -2e18, z = -2e18;
    if (!q1.empty())
        x = q1.front();
    if (!q2.empty())
        y = q2.front();
    if (!q3.empty());
        z = q3.front();
    if (x >= y && x >= z)
    {
        q1.pop();
        return x;
    }
    if (y >= x && y >= z)
    {
        q2.pop();
        return y;
    }
    if (z >= x && z >= y)
    {
        q3.pop();
        return z;
    }
}

int main()
{
    double p;
    int n, m, q, u, v, t, d, tot;
    long long mx, c1, c2;

    scanf("%d%d%d%d%d%d", &n, &m, &q, &u, &v, &t), tot = n + m;
    p = (double)u / v;
    for (int i = 1; i <= n; scanf("%d", &a[i]), ++i);
    sort(a + 1, a + n + 1, greater<int>());
    for (int i = 1; i <= n; ++i)
        q1.push((long long)a[i]);
    for (int i = 1; i <= m; ++i)
    {
        mx = Max() + d;
        d += q;
        c1 = floor(p * mx), c2 = mx - c1 - d, c1 -= d;
        (c1 >= c2) ? : (c1 ^= c2 ^= c1 ^= c2);
        q2.push(c1);
        q3.push(c2);
        (i % t) ? : printf("%lld ", mx);
    }
    putchar('\n');
    for (int i = 1; i <= tot; ++i)
    {
        mx = Max();
        (i % t) ? : printf("%lld ", mx + d);
    }
    return 0;
}

感觉像是爆内存了,但是明明在更大的数据量下过了的。。。

2023/1/19 09:23
加载中...