728x90
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
int count;
for(int i = 0; i < tc; i++) {
int n = sc.nextInt();
int m = sc.nextInt();
Queue<int[]> q = new LinkedList<>();
count = 0;
for(int j = 0; j < n; j++)
q.add(new int[] {j, sc.nextInt()});
while(!q.isEmpty()) {
int[] poll = q.poll();
boolean able = true;
for(int[] t : q)
if(t[1] > poll[1])
able = false;
if (able) {
count++;
if (poll[0]==m)
break;
}
else q.add(poll);
}
System.out.println(count);
}
}
}
728x90
'CS > Algorithm' 카테고리의 다른 글
ArrayList와 LinkedList의 차이점 [ Java ] (0) | 2021.04.04 |
---|---|
[백준 : 10773] 제로 - JAVA (0) | 2021.04.04 |
백준 2164 [큐] : 카드2 - JAVA (0) | 2021.03.29 |
백준 10845 큐 : JAVA (0) | 2021.03.28 |
JAVA : StringBuilder 메소드 (0) | 2021.03.28 |