본문 바로가기

OJ

[BOJ] 25757 임스와 함께하는 미니게임 (JAVA)

https://www.acmicpc.net/problem/25757

 

25757번: 임스와 함께하는 미니게임

첫 번째 줄에는 사람들이 임스와 같이 플레이하기를 신청한 횟수 $N$과 같이 플레이할 게임의 종류가 주어진다. $(1 \le N \le 100\,000)$ 두 번째 줄부터 $N$개의 줄에는 같이 플레이하고자 하는 사람들

www.acmicpc.net

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine(), " ");
        int N = Integer.parseInt(st.nextToken());
        char c = st.nextToken().charAt(0);

        Set<String> set = new HashSet<>();
        int cnt = 0;

        for (int i = 0; i < N; i++) {
            if (set.add(br.readLine())) cnt++;
        }

        if (c == 'Y') System.out.print(cnt);
        else if (c == 'F') System.out.print(cnt / 2);
        else System.out.print(cnt / 3);

    }

}

'OJ' 카테고리의 다른 글

[BOJ] 11365 !밀비 급일 (JAVA)  (2) 2023.03.02
[BOJ] 15904 UCPC는 무엇의 약자일까? (JAVA)  (0) 2023.03.01
[BOJ] 1159 농구 경기 (JAVA)  (0) 2023.02.27
[BOJ] 5525 IOIOI (JAVA)  (0) 2023.02.26
[BOJ] 20920 영단어 암기는 괴로워 (JAVA)  (0) 2023.02.25