【編程題解】Drive car

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!

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章