记录编号 220908 评测结果 AAAAAAAAAA
题目名称 [NOIP 2011]瑞士轮 最终得分 100
用户昵称 Gravatar铁策 是否通过 通过
代码语言 C++ 运行时间 0.809 s
提交时间 2016-01-20 18:28:25 内存使用 4.89 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;
int readint()
{
	int ans=0;
	char c;
	while (!isdigit(c=getchar()));
	do
	{
		ans=ans*10+c-'0';
		c=getchar();
	} while (isdigit(c));
	return ans;
}
struct player
{
	int s,w,o;
	player(int s=0,int w=0,int o=0):s(s),w(w),o(o){}
};
bool operator <(player a,player b)
{
	if (a.s!=b.s)
		return a.s<b.s;
	return a.o>b.o;
}
int n,r,q;
player a[200001],ls[200001];
void merge()
{
	int p1=1,p2=2,cnt=0;
	while (p1<=2*n && p2<=2*n)
	{
		cnt++;
		if (a[p1]<a[p2])
		{
			ls[cnt]=a[p1];
			p1+=2;
		}
		else
		{
			ls[cnt]=a[p2];
			p2+=2;
		}
	}
	for (int i=p1;i<=2*n;i+=2)
	{
		cnt++;
		ls[cnt]=a[i];
	}
	for (int i=p2;i<=2*n;i+=2)
	{
		cnt++;
		ls[cnt]=a[i];
	}
	for (int i=1;i<=2*n;i++)
		a[i]=ls[i];
}
int main()
{
	freopen("swiss.in","r",stdin);
	freopen("swiss.out","w",stdout);
	n=readint();
	r=readint();
	q=readint();
	for (int i=1;i<=2*n;i++)
		a[i]=player(readint(),0,i);
	for (int i=1;i<=2*n;i++)
		a[i].w=readint();
	sort(a+1,a+2*n+1);
	for (int k=0;k<r;k++)
	{
		for (int i=1;i<=2*n;i+=2)
		{
			if (a[i].w<a[i+1].w)
				swap(a[i],a[i+1]);
			a[i].s++;
		}		
		merge();
	}
	cout<<a[2*n-q+1].o<<endl;
	return 0;
}