백준 - 2563 : 색종이 [자바]

HungAh.log·2021년 8월 12일
0
post-custom-banner
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int N = Integer.parseInt(br.readLine()); //색종이 수
		boolean[][] paper = new boolean[100][100];
		
		int count = 0;
		for (int n = 0; n < N; n++) {
			StringTokenizer st = new StringTokenizer(br.readLine(), " ");
			int y = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			for (int i = 90 - x; i < 100 - x; i++) {
				for (int j = y; j < y+10; j++) {
					if (!paper[i][j]) {
						paper[i][j] = true;
						++count;
					}
					if (paper[i][j]) {
						continue;
					}
				}
			}
		}
		sb.append(count);
		System.out.println(sb);
	}
}
profile
👩🏻‍💻
post-custom-banner

0개의 댓글