-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
137 lines (110 loc) · 3.84 KB
/
Main.java
File metadata and controls
137 lines (110 loc) · 3.84 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package hashcode;
import hashcode.io.InputReader;
import hashcode.model.*;
import hashcode.strategy.*;
import java.io.*;
import java.util.*;
// hashcode2016@google.com
public class Main implements Runnable {
public InputReader in;
public PrintWriter out;
public static int TURNS;
public static int ROWS;
public static int COLS;
public static StringBuilder sb = new StringBuilder();
public static int CommandCount = 0;
public void solve() throws Exception {
// solution goes here
ROWS = in.nextInt();
COLS = in.nextInt();
int dronesCount = in.nextInt();
TURNS = in.nextInt();
Drone.MAX_WEIGHT = in.nextInt();
int productTypeCount = in.nextInt();
ProductType.PRODUCT_TYPE_COUNT = productTypeCount;
ProductType[] productTypes = new ProductType[productTypeCount];
for (int i = 0; i < productTypeCount; i++) {
productTypes[i] = new ProductType(i, in.nextInt());
}
ProductType.productTypes = productTypes;
int warehouseCount = in.nextInt();
Warehouse[] warehouses = new Warehouse[warehouseCount];
for (int i = 0; i < warehouseCount; i++) {
warehouses[i] = new Warehouse(i, new Point(in.nextInt(), in.nextInt()));
for (int j = 0; j < ProductType.PRODUCT_TYPE_COUNT; j++) {
warehouses[i].products[j] = in.nextInt();
}
}
Point point = warehouses[0].position;
Arrays.sort(warehouses, new Comparator<Warehouse>() {
@Override
public int compare(Warehouse o1, Warehouse o2) {
return - point.distanceTo(o1.position) + point.distanceTo(o2.position);
}
});
for (int i = 0; i < warehouses.length; i++){
warehouses[i].vid = i;
}
Warehouse.warehouses = warehouses;
Drone[] drones = new Drone[dronesCount];
for (int i = 0; i < dronesCount; i++) {
drones[i] = new Drone(i, new Point(warehouses[0].position));
}
Drone.drones = drones;
int orderCount = in.nextInt();
Order[] orders = new Order[orderCount];
for (int i = 0; i < orderCount; i++) {
orders[i] = new Order(i, new Point(in.nextInt(), in.nextInt()));
int items = in.nextInt();
for (int j = 0; j < items; j++) {
orders[i].addProduct(in.nextInt());
}
}
Order.orders = orders;
//new EduardStrategy().run();
AlexStrategy alexStrategy = new AlexStrategy();
alexStrategy.countForAllOrders();
}
public void run() {
try {
String filename = "redundancy";
in = new InputReader(new FileInputStream(filename + ".in"));
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename + ".out"))));
Strategy.out = out;
Locale.setDefault(Locale.US);
solve();
out.close();
} catch (Throwable e) {
e.printStackTrace();
System.exit(7);
}
}
static int abs(int x) {
return x < 0 ? -x : x;
}
static int max(int a, int b) {
return a > b ? a : b;
}
static int min(int a, int b) {
return a < b ? a : b;
}
static long abs(long x) {
return x < 0 ? -x : x;
}
static long max(long a, long b) {
return a > b ? a : b;
}
static long min(long a, long b) {
return a < b ? a : b;
}
public static void main(String args[]) {
new Thread(null, new Main(), "Main", 1 << 28).start();
}
static boolean OJ = System.getProperty("ONLINE_JUDGE") != null;
public void console(Object... objects) {
if (!OJ) {
out.println(Arrays.deepToString(objects));
out.flush();
}
}
}