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

Commit 2599a88

Browse files
authored
Add files via upload
1 parent 5f0ef83 commit 2599a88

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

Java/bin/angry.class

53 Bytes
Binary file not shown.

Java/src/angry.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,25 @@ public static int launchSim(int power){
1313
int cowsUsed = 0;
1414
int curCow = 0;
1515
int power2 = power*2;
16+
int l,range;
1617
// /int lastCow = field.get(field.size() - 1);
1718
while(curCow < N) {
1819
cowsUsed++;
1920
int pos = field.get(curCow);
20-
//curCow++;
21+
l = curCow + 1;
2122

23+
range =0;
2224
//System.out.println("Checking "+curCow + " In range "+curCow + " " + (curCow + 2 * power));
23-
for(int i = pos; i < N; i ++) {
25+
for(int i = l; i < N; i ++) {
2426

25-
if(field.get(i) < (pos + power2)) {
27+
if(field.get(i) <= pos + power2) {
2628
//System.out.println(field.get(i)+" In range "+i);
27-
curCow++;
29+
range++;
2830
}
2931
}
30-
curCow++;
31-
curCow++;
32+
//curCow++;
33+
curCow = curCow + range + 1;
34+
// curCow ++;
3235

3336
}
3437
return cowsUsed;
@@ -52,13 +55,13 @@ public static void main(String[] args) throws IOException{
5255
int m = (l + r) / 2;
5356
int t = launchSim(m);
5457
if (t < K) {
55-
r = m - 1;
58+
r = m;
5659
}else if(K == t) {
57-
//System.out.println("Got it");
58-
r = m - 1;
60+
// System.out.println("Got it");
61+
r = m;
5962
//break;
6063
}else {
61-
l = m+1;
64+
l = m;
6265
}
6366
}
6467

0 commit comments

Comments
 (0)