-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplatforme.java
75 lines (53 loc) · 1.14 KB
/
platforme.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import java.util.Scanner;
public class platforme {
static Scanner scan = new Scanner(System.in);
static int total = scan.nextInt();
static int[] y = new int[total];
static int[] x1 = new int[total];
static int[] x2 = new int[total];
public static int under1(int yy, int xx1)
{
int num = 0;
for(int i=0; i < total; i++)
{
if((yy > y[i] && xx1 >= x1[i] && xx1 < x2[i]))
{
if(yy-num > yy-y[i])
{
num = y[i];
}
}
}
return num;
}
public static int under2(int yy, int xx2)
{
int num = 0;
for(int i=0; i < total; i++)
{
if((yy > y[i] && xx2 > x1[i] && xx2 <= x2[i]))
{
if(yy-num > yy-y[i])
{
num = y[i];
}
}
}
return num;
}
public static void main(String[] args) {
for(int i=0; i < total; i++)
{
y[i] = scan.nextInt();
x1[i] = scan.nextInt();
x2[i] = scan.nextInt();
}
int count = 0;
for(int i=0; i < total; i++)
{
count += (y[i] - under1(y[i], x1[i]));
count += (y[i] - under2(y[i], x2[i]));
}
System.out.println(count);
}
}