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

Commit bb99832

Browse files
committed
Added line empty or not logic
1 parent 5065dbb commit bb99832

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/convention2.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,21 @@ public int compare(cow arg0, cow arg1) {
3434
int maxsenority;
3535
System.out.println(time);
3636
while(cows_eaten < N) {
37+
if(theline.isEmpty()) {
3738
tc = time.get(cows_eaten);
39+
}else {
40+
tc = theline.remove(0);
41+
}
3842
maxsenority = -1;
3943
cow nextcow = new cow(-1,-1); // Not guarented to have a conflicting time
4044
int j = 0;
4145
while(true) {
42-
j ++;
43-
if(time.get(cows_eaten + j).x >= tc.x+tc.y || theline.contains(time.get(cows_eaten + j))) { // If after the current cow is finsihed then all cows after it we don't have to worry about
46+
cows_eaten++;
47+
if(time.get(cows_eaten).x >= tc.x+tc.y || theline.contains(time.get(cows_eaten))) { // If after the current cow is finsihed then all cows after it we don't have to worry about
4448
break;
4549
}else {
46-
cows_eaten++;
47-
theline.add(time.get(cows_eaten + j));
50+
51+
theline.add(time.get(cows_eaten));
4852
}
4953
}
5054
nextcow.x = tc.x + tc.y; // When cow finishes

0 commit comments

Comments
 (0)