# You're on a remote island that needs evacuation due to pending flooding.
# The government is sending planes tomorrow to get some people out.
# If you miss the last plane you'd have to take a slower boat the following day which you don't want.
# Given the plane schedule and the schedule of all your fellow islanders,
# What is the latest you could get to the airport tomorrow and still get evacuated?
这道谷歌真题给了一个撤离小岛的场景:政府明天安排多班飞机,每个岛民都有自己的到达机场时间,飞机有固定起飞时间和座位数,先到先上。如果你赶不上所有航班,只能第二天坐慢船离开。题目要你在已知所有航班时刻表和其他岛民行程表的前提下,计算出“你还能保证上机的最晚到达时间”。本质上是一个时间表与容量分配问题,需要先对航班和到达时间排序,再用贪心或模拟方式分配座位,找到你不被挤掉的临界时间点。
正文完