forked from improper4/uva
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UVa00105_TheSkylineProblem.java
42 lines (36 loc) · 1.04 KB
/
UVa00105_TheSkylineProblem.java
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
package uva;
/* USER: 46724 (sfmunera) */
/* PROBLEM: 41 (105 - The Skyline Problem) */
/* SUBMISSION: 09203341 */
/* SUBMISSION TIME: 2011-08-29 18:32:47 */
/* LANGUAGE: 2 */
import java.util.*;
import java.io.*;
public class UVa00105_TheSkylineProblem {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line;
int[] height = new int[10010];
while ((line = in.readLine()) != null) {
StringTokenizer stk = new StringTokenizer(line);
int L = Integer.parseInt(stk.nextToken());
int H = Integer.parseInt(stk.nextToken());
int R = Integer.parseInt(stk.nextToken());
for (int i = L; i < R; ++i)
height[i] = Math.max(height[i], H);
}
String res = "";
int cur = -1;
for (int i = 1; i < height.length; ++i) {
if (height[i] != cur) {
if (i > 1)
res += " ";
res += i + " " + height[i];
cur = height[i];
}
}
System.out.println(res);
in.close();
System.exit(0);
}
}