-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNo_1085.java
More file actions
45 lines (35 loc) · 1.17 KB
/
No_1085.java
File metadata and controls
45 lines (35 loc) · 1.17 KB
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
41
42
43
44
45
/*
Problem_1085_직사각형에서 탈출
https://www.acmicpc.net/problem/1085
*/
import java.io.*;
import java.util.StringTokenizer;
public class No_1085 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(br.readLine());
int x, y, w, h;
x = Integer.parseInt(st.nextToken());
y = Integer.parseInt(st.nextToken());
w = Integer.parseInt(st.nextToken());
h = Integer.parseInt(st.nextToken());
br.close();
int rightBoundary = Math.abs(w - x);
int leftBoundary = x;
int topBoundary = Math.abs(h - y);
int bottomBoundary = y;
int min = -1;
if (rightBoundary >= leftBoundary)
min = leftBoundary;
else
min = rightBoundary;
if (min >= topBoundary)
min = topBoundary;
if(min >= bottomBoundary)
min = bottomBoundary;
bw.write(min + "");
bw.flush();
bw.close();
}
}