Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Method
- string
- two pointers
- Math
- geometry
- SQL
- array
- Counting
- Class
- 파이썬
- java
- simulation
- bit manipulation
- Binary Search
- Stack
- Data Structure
- 코딩테스트
- greedy
- implement
- 코테
- sorting
- database
- 구현
- Binary Tree
- hash table
- Number Theory
- Tree
- Matrix
- 자바
- dynamic programming
Archives
- Today
- Total
코린이의 소소한 공부노트
[백준 온라인 저지] 9063. 대지 본문
- 입력: 첫째 줄에는 점의 개수 N (1 ≤ N ≤ 100,000) 이 주어진다. 이어지는 N 줄에는 각 점의 좌표가 두 개의 정수로 한 줄에 하나씩 주어진다. 각각의 좌표는 -10,000 이상 10,000 이하의 정수이다.
- 출력: 첫째 줄에 N 개의 점을 둘러싸는 최소 크기의 직사각형의 넓이를 출력하시오.
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.valueOf(br.readLine()), answer = 0, xmin, xmax, ymin, ymax;
if(n>1){
String[] input = br.readLine().split(" ");
int a = Integer.valueOf(input[0]), b = Integer.valueOf(input[1]);
input = br.readLine().split(" ");
int c = Integer.valueOf(input[0]), d = Integer.valueOf(input[1]);
xmin = Math.min(a,c); xmax = Math.max(a,c);
ymin = Math.min(b,d); ymax = Math.max(b,d);
for(int i=2 ; i<n ; i++){
input = br.readLine().split(" ");
a = Integer.valueOf(input[0]); b = Integer.valueOf(input[1]);
xmin = Math.min(a,xmin); xmax = Math.max(a,xmax);
ymin = Math.min(b,ymin); ymax = Math.max(b,ymax);
}
answer = (ymax-ymin)*(xmax-xmin);
}
System.out.print(answer);
}
}
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[백준 온라인 저지] 5073. 삼각형과 세 변 (0) | 2023.03.29 |
---|---|
[백준 온라인 저지] 10101. 삼각형 외우기 (0) | 2023.03.29 |
[백준 온라인 저지] 15894. 수학은 체육과목입니다. (0) | 2023.03.29 |
[백준 온라인 저지] 3009. 네 번째 점 (0) | 2023.03.29 |
[백준 온라인 저지] 1085. 직사각형에서 탈출 (0) | 2023.03.29 |