-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Silver V] Title: 색종이, Time: 224 ms, Memory: 17872 KB -BaekjoonHub
- Loading branch information
1 parent
032127a
commit e5ec83a
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# [Silver V] 색종이 - 2563 | ||
|
||
[문제 링크](https://www.acmicpc.net/problem/2563) | ||
|
||
### 성능 요약 | ||
|
||
메모리: 17872 KB, 시간: 224 ms | ||
|
||
### 분류 | ||
|
||
구현 | ||
|
||
### 제출 일자 | ||
|
||
2024년 4월 18일 22:27:33 | ||
|
||
### 문제 설명 | ||
|
||
<p>가로, 세로의 크기가 각각 100인 정사각형 모양의 흰색 도화지가 있다. 이 도화지 위에 가로, 세로의 크기가 각각 10인 정사각형 모양의 검은색 색종이를 색종이의 변과 도화지의 변이 평행하도록 붙인다. 이러한 방식으로 색종이를 한 장 또는 여러 장 붙인 후 색종이가 붙은 검은 영역의 넓이를 구하는 프로그램을 작성하시오.</p> | ||
|
||
<p style="text-align: center;"><img alt="" src="https://u.acmicpc.net/6000c956-1b07-4913-83c3-72eda18fa1d1/Screen%20Shot%202021-06-23%20at%2012.27.04%20PM.png" style="width: 268px; height: 215px;"></p> | ||
|
||
<p>예를 들어 흰색 도화지 위에 세 장의 검은색 색종이를 그림과 같은 모양으로 붙였다면 검은색 영역의 넓이는 260이 된다.</p> | ||
|
||
### 입력 | ||
|
||
<p>첫째 줄에 색종이의 수가 주어진다. 이어 둘째 줄부터 한 줄에 하나씩 색종이를 붙인 위치가 주어진다. 색종이를 붙인 위치는 두 개의 자연수로 주어지는데 첫 번째 자연수는 색종이의 왼쪽 변과 도화지의 왼쪽 변 사이의 거리이고, 두 번째 자연수는 색종이의 아래쪽 변과 도화지의 아래쪽 변 사이의 거리이다. 색종이의 수는 100 이하이며, 색종이가 도화지 밖으로 나가는 경우는 없다</p> | ||
|
||
### 출력 | ||
|
||
<p>첫째 줄에 색종이가 붙은 검은 영역의 넓이를 출력한다.</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import java.util.Scanner; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
|
||
int[][] paper = new int[100][100]; | ||
int count = scanner.nextInt(); | ||
|
||
for (int i = 0; i < count; i++) { | ||
int a = scanner.nextInt(); | ||
int b = scanner.nextInt(); | ||
for (int j = a; j < a + 10; j++) { | ||
for (int k = b; k < b + 10; k++) { | ||
paper[k][j] = 1; | ||
} | ||
} | ||
} | ||
|
||
int res = 0; | ||
for (int i = 0; i < 100; i++) { | ||
for (int j = 0; j < 100; j++) { | ||
if (paper[i][j] == 1) { | ||
res += paper[i][j]; | ||
} | ||
} | ||
} | ||
System.out.println(res); | ||
} | ||
} |