본문 바로가기
알고리즘 & 자료구조/백준

백준 1159

by 신재권 2022. 1. 31.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main1159 {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine()); //선수 수 N
		String [] p = new String[N];
		int[] a = new int[26];
		
		
		for(int i=0; i<N; i++) {
			p[i] = br.readLine();
			a[p[i].charAt(0)-'a']++;
		}
		
		int state = 0;
		
		for(int i=0; i<26; i++) {
			if(a[i] >= 5) {
				state = 1;
				char c = (char) (i+'a');
				System.out.print(c);
			}
		}
		if(state == 0) {
			System.out.println("PREDAJA");
		}
		
		
	}
	
	
	
}

 

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 11655  (0) 2022.02.02
백준 10988_1  (0) 2022.02.01
백준 10988  (0) 2022.01.30
백준 2979  (0) 2022.01.29
백준 10808  (0) 2022.01.28