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);
}