求助 T3 暴力 0pts
  • 板块学术版
  • 楼主Micnation_AFO
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/9/10 18:02
  • 上次更新2023/10/27 12:06:42
查看原帖
求助 T3 暴力 0pts
574944
Micnation_AFO楼主2022/9/10 18:02

rt,感觉思路挺清晰的,但就是不知道为什么 WA

#include <iostream>
#include <queue>

using namespace std;

const int N = 2000010;
const int INF = 1e9;

struct array {
    int a, b;
    int id;
    bool operator > (const array &x) const {
        if (a == x.a && b == x.b) return id < x.id;
        if (b == x.b) return a > x.a;
        return b > x.b;
    }
    bool operator < (const array &x) const {
        if (a == x.a && b == x.b) return id > x.id;
        if (b == x.b) return a < x.a;
        return b < x.b;
    }
} a[N], b[N];

int n, m, v;
int Max[N];

int main() {
    scanf("%d%d%d", &n, &m, &v);
    int res = -INF, id;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i].a);
        a[i].b = a[i].a, a[i].id = i;
    }
    int ans1 = 0, ans2 = 0;
    while (m--) {
        int x, k; scanf("%d %d", &x, &k);
        if (x + k - 1 > n) continue;
        priority_queue<array> q;
        int sta;
        for (int i = 1; i <= n; i++) b[i] = a[i];
        int res = 0, sum = 0;
        q.push((array){-INF, -INF, INF});
        for (int i = 1; ; i++) {
            if (sum >= k) break;
            if (i >= x) {
                sum++;
                if (i == x) {
                    sta = a[i].a;
                    b[i].b = b[i].a = q.top().b;
                    if (b[i] < q.top()) b[i].b++;
                    res = max(res, b[i].b);
                    q.push(b[i]);
                }
                else {
                    if (!(b[i] < q.top())) {
                        array l = q.top(); q.pop();
                        res = b[i].b; l.b = b[i].b;
                        if (l < b[i]) l.b++, res++;
                        l.b += v;
                        q.push(l); q.push(b[i]);
                    }
                }
                continue;
            }
            q.push(b[i]);
            array l = q.top(); q.pop();
            b[l.id].b += v;
            q.push(b[l.id]);
        }
        ans1 ^= res, ans2 += res;
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}
2022/9/10 18:02
加载中...