https://www.acmicpc.net/problem/27918
import java.util.Scanner;
import java.util.ArrayList;
import java.lang.Math;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int numOfGame = sc.nextInt();
ArrayList<String> winnerList = new ArrayList<String>();
for (int i = 0; i < numOfGame; i++) {
winnerList.add(sc.next());
}
int Dscore = 0;
int Pscore = 0;
for (int i = 0; i < winnerList.size(); i++) {
String winner = winnerList.get(i);
if (winner.equals("D")) {
Dscore++;
} else if (winner.equals("P")) {
Pscore++;
}
int gap = Math.abs(Dscore - Pscore);
if (gap >= 2) {
break;
}
}
System.out.println(Dscore + ":" + Pscore);
}
}
'study > 알고리즘 문제 풀이' 카테고리의 다른 글
유기농 배추 (백준 1012) (0) | 2023.05.13 |
---|---|
BFS와 DFS (백준 1260) (0) | 2023.05.03 |
[python] 2293 동전1 (0) | 2022.06.09 |
[python] 1026 보물 (0) | 2022.06.09 |
[python] 1002 터렛 (0) | 2022.06.09 |