试题描述
|
输入
|
输出
|
输入示例
|
2 4 2 7 6 6 7 10 5 20 15 |
输出示例
|
1
|
其他说明
|
C程序:
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
int N,R,Q;
struct node
{
int s,w,p;
}t[210000],first[210000],second[210000];
bool cmp(node x,node y)
{
if(x.s<y.s) return false;
if(x.s>y.s) return true;
if(x.p<y.p) return true;
return false;
}
void input()
{
scanf("%d%d%d",&N,&R,&Q);
for(int i=1;i<=2*N;i++) scanf("%d",&t[i].s);
for(int i=1;i<=2*N;i++) scanf("%d",&t[i].w);
for(int i=1;i<=2*N;i++) t[i].p=i;
}
void work()
{
sort(t+1,t+2*N+1,cmp);
while(R--)
{
for(int i=1;i<=2*N;i+=2)
if(t[i].w>t[i+1].w)
{
t[i].s++;
first[(i+1)/2]=t[i];
second[(i+1)/2]=t[i+1];
}
else
{
t[i+1].s++;
first[(i+1)/2]=t[i+1];
second[(i+1)/2]=t[i];
}
int x=1,y=1,cnt=0;
while(x<=N && y<=N)
if(first[x].s>second[y].s)
t[++cnt]=first[x++];
else if(first[x].s<second[y].s)
t[++cnt]=second[y++];
else
{
if(first[x].p<second[y].p)
t[++cnt]=first[x++];
else
t[++cnt]=second[y++];
}
while(x<=N) t[++cnt]=first[x++];
while(y<=N) t[++cnt]=second[y++];
//sort(t+1,t+2*N+1,cmp);
}
printf("%d\n",t[Q].p);
}
int main()
{
input();
work();
return 0;
}