문제

https://www.acmicpc.net/problem/2563


문제 풀이

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
import java.util.*;

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

        int n = sc.nextInt();
        int[][] arr = new int[100][100];

        int cnt = 0;

        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            for (int j = x; j < x + 10; j++) {
                for (int k = y; k < y + 10; k++) {
                    arr[j][k] = 1;
                }
            }
        }

        for (int[] nums : arr) {
            for (int num : nums) {
                if (num == 1) cnt++;
            }
        }

        System.out.println(cnt);
    }
}

카테고리:

업데이트:

댓글남기기