forked from aviraw/CodeChef
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUJ
39 lines (39 loc) · 705 Bytes
/
UJ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
for(int i=0;i<t;i++)
{
int n;
cin>>n;
int a[n];
for(int j=0;j<n;j++)
{
cin>>a[j];
}
int key;
cin>>key;
key=a[key-1];
for(int j=0;j<n;j++)
{
for(int k=0;k<n-j-1;k++)
{
if(a[k]>a[k+1])
{
int t=a[k];
a[k]=a[k+1];
a[k+1]=t;
}
}
}
for(int j=0;j<n;j++)
{
if(key==a[j])
key=j;
}
cout<<key+1<<endl;
}
return 0;
}