카드게임
in Algorithm on SW Expert Academy
Software Expert Academy [9778] 카드게임
소스코드
import java.util.Scanner;
public class Solution {
static String ans;
static int[] card;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int tc = 1; tc <= T; tc++) {
// 카드 갯수 초기화
card = new int[12];
for (int i = 2; i < card.length; i++) {
if ((i >= 2 && i <= 9) || i == 11)
card[i] = 4;
else if (i == 10)
card[i] = 16;
}
// 뽑은 카드
int sum = 0;
int N = sc.nextInt();
for (int i = 0; i < N; i++) {
int num = sc.nextInt();
sum += num;
card[num]--;
}
ans = "";
if (sum >= 21) {
ans = "STOP";
} else {
pickCard(sum);
}
System.out.println("#" + tc + " " + ans);
}
}
public static void pickCard(int sum) {
int big = 0;
int small = 0;
for (int i = 2; i < card.length; i++) {
while (card[i] > 0) {
int chk = sum + i;
if (chk > 21) {
big++;
} else {
small++;
}
card[i]--;
}
}
if (big >= small)
ans = "STOP";
else
ans = "GAZUA";
}
}