瑞士轮

http://icpc.upc.edu.cn/problem.php?cid=1680&pid=0

#include<cstdio>
#include<algorithm>
using namespace std;
struct str
{
    int s,z,n;
    bool operator <(const str& str1)const
    {
        if(s!=str1.s)
            return s>str1.s;
        return n<str1.n;
    }
} a[200005],l[100005],r[100005];
int n,m,q,i1,i2,i;
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    for(i=1; i<=2*n; i++)
        scanf("%d",&a[i].s);
    for(i=1; i<=2*n; i++)
    {
        scanf("%d",&a[i].z);
        a[i].n=i;
    }
    sort(a+1,a+2*n+1);
    while(m--)
    {
        for(int i=2; i<=2*n; i+=2)
            if(a[i-1].z>a[i].z)
            {
                a[i-1].s++;
                l[i/2]=a[i-1];
                r[i/2]=a[i];
            }
            else
            {
                a[i].s++;
                l[i/2]=a[i];
                r[i/2]=a[i-1];
            }
       /* i1=1;
		i2=1;
		i=1;
		while (i1<=n&&i2<=n)
		if (l[i1]<r[i2]) a[i++]=l[i1++];else a[i++]=r[i2++]; 
		while (i1<=n)
		a[i++]=l[i1++];
		while (i2<=n)
		a[i++]=r[i2++]; */
		merge(l+1,l+n+1,r+1,r+n+1,a+1);
    }
    printf("%d\n",a[q].n);
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值