-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStars.java
More file actions
43 lines (43 loc) · 1.43 KB
/
Copy pathStars.java
File metadata and controls
43 lines (43 loc) · 1.43 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
/*
Enter your code here. Read input from STDIN. Print output to STDOUT
Your class should be named Solution
*/
import java.util.*;
public class Solution {
public static void main (String args []) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int points [][] = new int [n][2];
int weights [] = new int [n];
double y [] = new double[n];
for (int i = 0; i < n; i++) {
points[i][0] = scanner.nextInt();
points[i][1] = scanner.nextInt();
weights[i] = scanner.nextInt();
}
double step = Math.PI / 1000;
int max = -1;
for (double angle = 0; angle <= Math.PI; angle += step) {
for (int i = 0; i < n; i++) {
y[i] = points[i][0] * Math.cos(angle) - points[i][1] * Math.sin(angle);
}
for (int i = 0; i < n; i++) {
double cut = y[i];
int left = 0;
int right = 0;
for (int j = 0; j < n; j++) {
if (y[j] <= cut) {
left += weights[j];
} else {
right += weights[j];
}
int tmpMin = Math.min(left, right);
if (tmpMin > max) {
max = tmpMin;
}
}
}
}
System.out.println(max);
}
}