Description
n individuals want to travel, the place to stay is far from the restaurant, you need to drive by, but there is only one car in the hotel
The car can sit for a maximum of three people at a time, and each person drives to the restaurant alone for a[i];
When two or three people take a car together, the time spent is the longest driving time among all of them;
For safety, at least two people are required to drive at a time.
So what is the shortest time it takes to get everyone to the restaurant.
Input
The first line is an integer T, indicating the number of test samples.
The first line of each test sample is a positive integer n, indicating the number of people participating in the tour.
The second line is n positive integers a[i], representing the time when n people drive to restaurant alone;
Data range:2≤n<100000,0<a[i]<100000
Output
For each test sample, a minimum driving time is output.
Each result is on a line.
Sample Input 1
2
2
1 2
4
1 1 1 1
Sample Output 1
2
3
Personal Answer (using language:JAVA) Not necessarily right
public class Main {
public static void main(String[] args) {
System.out.println("Unsolved");
}
}
Welcome to communicate!
这是一道编程题,题目要求解决n个人去餐厅的问题,只有一辆车且每次最多载三人。每个人的独自驾驶时间不同,当两人或三人同行时,驾驶时间取他们中最长的。为了安全至少需要两人同行。目标是最短时间将所有人送到餐厅。输入包括测试样例数、人数及每个人的独自驾驶时间,输出是最短驾驶时间。已给出个人用JAVA编写的不一定正确的解答,欢迎交流。
822

被折叠的 条评论
为什么被折叠?



