문제 링크
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Solution_3499 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int t=0;t<T;t++) {
Queue<String> q1 = new LinkedList<>();
Queue<String> q2 = new LinkedList<>();
int N = sc.nextInt();
for(int i=0;i<N;i++)
q2.offer(sc.next());
//System.out.println(N);
int num = (N%2)==0?N/2:(N/2+1);
//System.out.println(num);
for(int i=0;i<num;i++) {
//System.out.println(q2.peek());
q1.offer(q2.poll());
}
System.out.print("#"+(t+1)+" ");
for(int i=0;i<N;i++) {
if(i%2 == 0)
System.out.print(q1.poll()+" ");
else
System.out.print(q2.poll()+" ");
}
System.out.println();
/*q1.clear();
q2.clear();*/
}
}
}
중간에 문제를 살짝 잘못 이해했당.
'알고리즘 > SWExpert' 카테고리의 다른 글
[JAVA]SWExpert_5215_햄버거다이어트 (0) | 2021.02.08 |
---|---|
SWExpert_1223_계산기2 (0) | 2021.02.06 |
SWExpert_1225_암호생성기 (1) | 2021.02.04 |
SWExpert_2001_파리퇴치 (0) | 2021.02.03 |
SWExpert_2805_농작물 수확하기 (0) | 2021.02.03 |