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

Commit 7d601ba

Browse files
committed
more code...
1 parent b8ccaf0 commit 7d601ba

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/convention2.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,39 @@ public int compare(cow arg0, cow arg1) {
2828
List<cow> theline = new ArrayList<cow>();
2929
int c1; // Cache calculations
3030
cow tc = new cow(-2,-2);
31-
int mtime = -1,ctime;
31+
int mtime = -1,ctime,waittime;
32+
ctime = 0;
3233
cow c2;
3334
int cows_eaten = 0;
3435
int maxsenority;
3536
System.out.println(time);
3637
while(cows_eaten < N) {
3738
if(theline.isEmpty()) {
38-
tc = time.get(cows_eaten);
39+
tc = time.get(cows_eaten);
40+
3941
}else {
40-
tc = theline.remove(0);
42+
43+
tc = theline.remove(0);
44+
waittime = ctime - tc.x;
45+
if(waittime > mtime) {
46+
mtime = waittime;
47+
}
4148
}
49+
ctime = ctime + tc.y;
4250
maxsenority = -1;
4351
cow nextcow = new cow(-1,-1); // Not guarented to have a conflicting time
4452
int count = 0;
4553
while(true) {
4654
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
55+
if(time.get(cows_eaten).x >= ctime || 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
4856
break;
4957
}else {
5058
count ++;
5159
theline.add(time.get(cows_eaten));
5260
}
5361
}
5462
if(count>0) {theline.sort(cowcompare);}
55-
nextcow.x = tc.x + tc.y; // When cow finishes
63+
5664

5765
}
5866

0 commit comments

Comments
 (0)