#P7757. [COCI 2012/2013 #3] AERODROM
[COCI 2012/2013 #3] AERODROM
Description
A delegation of a certain country, consisting of people, is traveling to Australia to participate in IOI 2013. They are currently waiting in line at the airport to check in. There are check-in counters open. Some officers work more efficiently than others, so the counters operate at different speeds. At the -th counter, it takes seconds to complete the check-in for one passenger, and the delegation members happen to know these exact numbers.
At the beginning, all counters are ready to accept the next passenger, and now only the members of our delegation are allowed to queue. A person can take an available counter and start checking in only after everyone in front of them has left the queue (started check-in, not necessarily finished). At that moment, the person may immediately take an idle counter (if there is one), but they may also choose to wait for another counter with faster processing time to become idle.
The delegation members are computer science geniuses, and they decide to have everyone finish check-in as early as possible. Your task is to find the minimum time needed to finish check-in.
Input Format
The input has a total of lines.
The first line contains two integers , representing the number of counters and the number of people in the delegation.
The next lines each contain one integer , meaning the time needed for the -th counter to process one passenger’s check-in.
Output Format
Output only one line with one integer, indicating the minimum time needed to finish check-in (in seconds).
2 6
7
10
28
7 10
3
8
3
6
9
2
4
8
Hint
[Sample 1 Explanation]
For Sample , there are two counters with processing times seconds and seconds. Among the six people in the delegation, the first two people immediately take these two counters. At second , the first counter becomes idle, and the third person takes it. At second , the fourth person takes the second counter. At second , the fifth person takes the first counter. At second , the second counter becomes idle again, but the sixth person decides to wait one more second (until second ) so that the first counter becomes idle, and then takes it. In this way, check-in can be completed in seconds. If the sixth person did not wait for the faster counter, check-in would take seconds.
[Constraints]
There are test points in total. The constraints for each test point are shown in the table below:
| Test Point ID | |||
|---|---|---|---|
[Source]
This problem comes from COCI 2012-2013 CONTEST 3 T4 AERODROM. With the original testdata configuration, the full score is points.
Translated and整理 (zhěnglǐ: compiled/edited) by Eason_AC.
Translated by ChatGPT 5
京公网安备 11011102002149号