Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit cd2a096

Browse files
authored
Add files via upload
1 parent 118c82a commit cd2a096

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Java/angry.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8
1+
-1

Java/bin/angry.class

535 Bytes
Binary file not shown.

Java/src/angry.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
public class angry {
88
static List<Integer> field = new ArrayList<Integer>();
99
public static int N;
10+
1011
public static int launchSim(int power){
1112
int cowsUsed = 0;
1213
int curCow = 0;
14+
// /int lastCow = field.get(field.size() - 1);
1315
while(curCow < N) {
1416
int pos = field.get(curCow);
1517
curCow++;
1618
for(int i = pos; i < N; i ++) {
17-
if(pos ) {
19+
if(field.get(i) < pos + 2 * power) {
1820
curCow++;
1921
}
2022
}
23+
cowsUsed++;
2124
}
2225
return cowsUsed;
2326
}
@@ -37,7 +40,7 @@ public static void main(String[] args) throws IOException{
3740
int r = N;
3841
while (r - l > 1) {
3942
int m = (l + r) / 2;
40-
if (launchSim(m) < K) {
43+
if (launchSim(m) > K) {
4144
r = m;
4245
} else {
4346
l = m;
@@ -46,10 +49,13 @@ public static void main(String[] args) throws IOException{
4649

4750
System.out.println(field);
4851
//System.out.println(costs);
49-
52+
System.out.println(l +" "+r);
5053
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("angry.out")));
5154
pw.println(answer);
5255
pw.close();
56+
for(int i = 0 ; i < N; i ++) {
57+
System.out.println(i+": "+launchSim(N));
58+
}
5359
//System.out.println("");
5460
}
5561

0 commit comments

Comments
 (0)