请求加强数据
查看原帖
请求加强数据
928879
stripe_python楼主2023/12/16 17:17

RT,没有用归并,stable_sort 最慢的点 279ms。

#include <bits/stdc++.h>
#define N 200005
using namespace std;

#define SZ (1 << 14)
char buf[SZ], *p1, *p2;
#define getchar() (p1 == p2 ? (p2 = buf + fread(p1 = buf, 1, SZ, stdin), p1 == p2 ? EOF : *p1++) : *p1++)
template <typename T>
inline void read(T& x) {
	x = 0; int t = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') t = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= t;
}

int n, r, q;
struct data {
	int i, s, w;
	
	bool operator< (const data& x) const {
		if (s == x.s) return i < x.i;
		return s > x.s;
	}
} a[N];

int main() {
	read(n), read(r), read(q);
	for (register int i = 1; i <= (n << 1); i++) a[i].i = i, read(a[i].s);
	for (register int i = 1; i <= (n << 1); i++) read(a[i].w);
	while (r--) {
		stable_sort(a + 1, a + (n << 1) + 1);
		for (register int i = 1; i <= (n << 1); i += 2) {
			if (a[i].w > a[i + 1].w) a[i].s++;
			else a[i + 1].s++;
		}
	}
	stable_sort(a + 1, a + (n << 1) + 1);
	cout << a[q].i;
	return 0;
}

2023/12/16 17:17
加载中...