• 문제 링크
10774번: 저지
학교 대표팀은 1부터 번호가 매겨진 저지를 학생 선수들에게 배분하고자 한다. 저지의 사이즈는 S, M, L 중 하나이다 (물론 S=small, M=medium, L=Large다). 각각의 선수들은 구체적인 저지의 번호와 선호
www.acmicpc.net
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = read(), m = read();
int[] arr = new int[n + 1];
for (int i = 1; i <= n; i++) arr[i] = convert(read());
int cnt = 0;
while (m-- > 0) {
int c = convert(read()), i = read();
if (arr[i] != 0 && arr[i] <= c) {
arr[i] = 0;
cnt++;
}
}
bw.write(String.valueOf(cnt));
bw.flush();
}
private static int convert(int i) {
return i == 12 ? 1 : (i == 13 ? 2 : 3);
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 2864 5와 6의 차이 - Greedy / Java (0) | 2024.01.13 |
---|---|
[백준] 10263 Opening Ceremony - Greedy / Java (0) | 2024.01.12 |
[백준] 5991 Papaya Jungle - Graph Theory / Java (0) | 2024.01.10 |
[백준] 26999 Satellite Photographs - Graph Theory / Java (0) | 2024.01.09 |
[백준] 6018 Tea Time - Graph Theory / Java (0) | 2024.01.08 |
댓글