vollmond
By: a guest | Jul 20th, 2008 | Syntax:
Groovy | Size: 1.58 KB | Hits: 112 | Expires: Never
#!/usr/bin/env groovy
class ImprovedTimetable
{
println "Usage: <command> <path to input>"
}
testCase++
trips = []
turnaround = i.next().toInteger()
def numTrips
= i.
next().
split()
numTrips
[0
].
toInteger().
times() {
trips.
add([depart:convert
(times[0
]), arrive:convert
(times[1]), source:
"A"])
}
numTrips
[1
].
toInteger().
times() {
trips.
add([depart:convert
(times[0
]), arrive:convert
(times[1]), source:
"B"])
}
processData()
}
}
return (time
[0
].
toInteger() * 60
) + time
[1
].
toInteger()
}
def starting
= [A:0, B:0
]
available = [A:0, B:0]
trips
= trips.
sort { it.
depart }
curTime = trip.depart
updateTimes(curTime)
if (available
[trip.
source] > 0
) {
available[trip.source]--
starting[trip.source]++
}
}
println "Case #${testCase}: ${starting["A
"]} ${starting["B
"]}"
}
if (trips
[i
].
arrive + turnaround
<= curTime
&& ! trips
[i
].
done) {
available["A" == trips[i].source ? "B" : "A"]++
}
}
}
}