标签:put lock result 思路 nta nal cti eth struct
描述:
As we all know, Brexit negotiations are on their way—but we still do not know whether they will actually finish in time.
The negotiations will take place topic-by-topic. To organise the negotiations in the most effective way, the topics will all be discussed and finalised in separate meetings, one meeting at a time.
This system exists partly because there are (non-cyclic) dependencies between some topics: for example, one cannot have a meaningful talk about tariffs before deciding upon the customs union. The EU can decide on any order in which to negotiate the topics, as long as the mentioned dependencies are respected and all topics are covered.
Each of the topics will be discussed at length using every available piece of data, including key results from past meetings. At the start of each meeting, the delegates will take one extra minute for each of the meetings that has already happened by that point, even unrelated ones, to recap the discussions and understand how their conclusions were reached. See the figure for an example.
Nobody likes long meetings. The EU would like you to help order the meetings in a way such that the longest meeting takes as little time as possible.
Illustration of how time is spent in each meeting in a solution to Sample Input 2.
Input
The input consists of:
One line containing an integer nn (), the number of topics to be discussed. The topics are numbered from 11 to nn.
nn
lines, describing the negotiation topics.
The iith such line starts with two integers eiei and didi (1≤ei≤1061≤ei≤106, 0≤di<n0≤di<n), the number of minutes needed to reach a conclusion on topic ii and the number of other specific topics that must be dealt with before topic ii can be discussed.
The remainder of the line has di distinct integers , the list of topics that need to be completed before topic ii.
It is guaranteed that there are no cycles in the topic dependencies, and that the sum of didi over all topics is at most 4⋅1054⋅105.
Output
Output the minimum possible length of the longest of all meetings, if meetings are arranged optimally according to the above rules.
题目大意:给出n个会议,包括会议时间和该会议需要的前提会议(必须开完前提会议才可以开这个会议)。求一个会议顺序使得最长的会议时间最短(这里的会议时间是指会议时间加会议序号减1)。
读完题,感觉应该是堆加拓扑排序。然后立刻写了一发: