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

Commit b8ccaf0

Browse files
committed
Senority sort
1 parent 430b23d commit b8ccaf0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/convention2.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@ public int compare(cow arg0, cow arg1) {
4141
}
4242
maxsenority = -1;
4343
cow nextcow = new cow(-1,-1); // Not guarented to have a conflicting time
44-
int j = 0;
45-
while(true) {
44+
int count = 0;
45+
while(true) {
4646
cows_eaten++;
4747
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
4848
break;
4949
}else {
50+
count ++;
5051
theline.add(time.get(cows_eaten));
5152
}
5253
}
53-
theline.sort(cowcompare);
54+
if(count>0) {theline.sort(cowcompare);}
5455
nextcow.x = tc.x + tc.y; // When cow finishes
5556

5657
}

0 commit comments

Comments
 (0)