mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
49 lines
968 B
C++
49 lines
968 B
C++
|
#include<stdio.h>
|
||
|
#include<string.h>
|
||
|
#include<iostream>
|
||
|
#include<algorithm>
|
||
|
#include<queue>
|
||
|
using namespace std;
|
||
|
struct point
|
||
|
{
|
||
|
int pla, num;
|
||
|
};
|
||
|
int cmp(int x, int y)
|
||
|
{
|
||
|
return x>y;
|
||
|
}
|
||
|
int main()
|
||
|
{
|
||
|
int T, i, n, m;
|
||
|
scanf("%d", &T);
|
||
|
while(T--)
|
||
|
{
|
||
|
point p[105];
|
||
|
int a[105];
|
||
|
queue<point>Q;
|
||
|
scanf("%d%d", &n, &m);
|
||
|
for(i=0; i<n; i++)
|
||
|
{
|
||
|
scanf("%d", &a[i]);
|
||
|
p[i].num=a[i], p[i].pla=i;
|
||
|
Q.push(p[i]);
|
||
|
}
|
||
|
sort(a, a+n, cmp);
|
||
|
int maxtop=0;
|
||
|
int num=1;
|
||
|
while(1)
|
||
|
{
|
||
|
point x=Q.front();
|
||
|
Q.pop();
|
||
|
if(x.num==a[maxtop]&&x.pla!=m)
|
||
|
maxtop++, num++;
|
||
|
else if(x.num==a[maxtop]&&x.pla==m)
|
||
|
break;
|
||
|
else
|
||
|
Q.push(x);
|
||
|
}
|
||
|
printf("%d\n", num);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|