Home B2605. 색종이
Post
Cancel

B2605. 색종이

문제

image

제출 코드

image

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package bronze;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class B2563_colorPaper {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int SIZE = 100;
		int N = sc.nextInt();
		boolean[][] arr = new boolean[SIZE][SIZE];

		int x, y;
		for(int n=0; n<N; n++) {
			x = sc.nextInt()-1;
			y = sc.nextInt()-1;

			for(int i=x; i<x+10; i++) {		//색종이 붙이기
				for(int j=y; j<y+10; j++) {
					arr[i][j] = true;
				}
			}

		}

		int count = 0;
		for(int i=0; i<SIZE; i++) {			//붙은 면적 세기
			for(int j=0; j<SIZE; j++) {
				if(arr[i][j]) count++;
			}
		}

		System.out.println(count);

	}

}
This post is licensed under CC BY 4.0 by the author.