-
[백준] 13300 방 배정ALGORITHM/BOJ 2020. 11. 6. 23:01
2020-11-06
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static int N, K, count, arr[][]; public static void solve() { for(int i = 0; i < 6; i++) { if(arr[i][0] >= 1) { count += (arr[i][0] / K); count += (arr[i][0] % K == 0) ? 0 : 1; } if(arr[i][1] >= 1) { count += (arr[i][1] / K); count += (arr[i][1] % K == 0) ? 0 : 1; } } } public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(bf.readLine()); N = Integer.parseInt(st.nextToken()); K = Integer.parseInt(st.nextToken()); arr = new int[6][2]; count = 0; for(int i = 0; i < N; i++) { st = new StringTokenizer(bf.readLine()); int x = Integer.parseInt(st.nextToken()); int y = Integer.parseInt(st.nextToken()); arr[y-1][x]++; } solve(); System.out.println(count); } }
단순하게 생각해서 푼 문제, 효율적이지는 못한 방법 같다
'ALGORITHM > BOJ' 카테고리의 다른 글
[백준] 1149 RGB거리 (0) 2020.11.07 [백준] 2606 바이러스 (0) 2020.11.06 [백준] 14503 로봇 청소기 (0) 2020.11.03 [백준] 9095 1, 2, 3 더하기 (0) 2020.11.02 [백준] 2638 치즈 (0) 2020.10.29