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 | 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]; //도화지가 100 100이라 했으니깐 int count = 0; for(int i=0;i<N;i++) { int X = sc.nextInt(); //왼쪽 모서리 위 가로축 위치 int Y = sc.nextInt(); //왼쪽 모서리 위 세로축 위치 for(int a=X;a<X+10;a++) { for(int b=Y;b<Y+10;b++) arr[a][b] = 1; } } // 넓이가 10 10인 색종이니깐 for(int i=0;i<100;i++) { for(int j=0;j<100;j++) { if(arr[i][j]==1) count++; //다시 한번 돌면서 1인 부분 = 즉 색종이가 차있는 부분을 카운트 해줌 } } System.out.println(count); } } | cs |
'Algorithm' 카테고리의 다른 글
백준 2720 세탁소 사장 동혁 (0) | 2023.08.29 |
---|---|
백준 10798 세로 읽기 (1) | 2023.08.29 |
백준 단어 공부 1157 (1) | 2023.08.28 |
백준 10988 팰린드롬인지 (1) | 2023.08.28 |
백준 평균 1546 (1) | 2023.08.26 |