forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJOHNY.c
51 lines (43 loc) · 753 Bytes
/
JOHNY.c
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
40
41
42
43
44
45
46
47
48
49
50
//Author: Rakshit Naidu
#include <stdio.h>
int main(void) {
// your code goes here
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
int k;
scanf("%d",&k);
int temp = 0;
int x = a[k-1];
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i] > a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
int pos=0;
for(int i=0;i<n;i++)
{
if(x == a[i])
{
pos = i+1;
}
}
printf("%d\n",pos);
}
return 0;
}