Hi Quoc Khanh Thai,
After sorting end time, you are using the start time of the sorted end time
to assign tasks, which means that the start times are unsorted. Hence, the
answer turns out to be incorrect.
For example, check the below example,
1
5
1 100
100 120
100 150
300 400
130 500
here the end times are already sorted,
now in the above code:
1 100 will be assigned to C
100 120 will be assigned to C
100 150 will be assigned to J
300 400 will be assigned to C
130 500 cannot be assigned to anyone.... but the correct answer is CJCCJ
or JCJJC
So, in the above code, if endTime is instead used for comparison:
like this in all the places, it should work fine:
> if (endTime >= cameronLastTask) {
plannedSchedule[index]='C';
cameronLastTask = startTime;
}
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/48a6eba9-a8fa-4149-ad76-9349af9e3887%40googlegroups.com.