重载
2026-06-20 09:53:28
发布于:广东
1阅读
0回复
0点赞
#include <iostream>
#include <algorithm>
using namespace std;
const int M = 2e5+5;
struct P {
int s, w, id;
bool operator<(const P& o) const {
return s != o.s ? s > o.s : id < o.id;
}
} a[M], w[M], l[M];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, r, q;
cin >> n >> r >> q;
int tot = n * 2;
for (int i = 0; i < tot; ++i) cin >> a[i].s, a[i].id = i + 1;
for (int i = 0; i < tot; ++i) cin >> a[i].w;
sort(a, a + tot);
while (r--) {
int cw = 0, cl = 0;
for (int i = 0; i < tot; i += 2) {
P x = a[i], y = a[i+1];
if (x.w > y.w) ++x.s, w[cw++] = x, l[cl++] = y;
else ++y.s, w[cw++] = y, l[cl++] = x;
}
int i = 0, j = 0, p = 0;
for (; i < cw && j < cl; ++p)
a[p] = w[i] < l[j] ? w[i++] : l[j++];
for (; i < cw; ++p) a[p] = w[i++];
for (; j < cl; ++p) a[p] = l[j++];
}
cout << a[q-1].id;
return 0;
}
好像没有人用重载运算符哦
这里空空如也





有帮助,赞一个