아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Fujiyama Thursday

시간 제한1초메모리 제한1024 MB

요약
도착 시간이 주어진 c대의 차에 4c명의 팀원을 배정해 마지막 사람이 식사를 마치는 시간을 최소로 만든다.
난이도

보통10점 중 4점

유형
그리디, 정렬
정답자
아직 제출이 없습니다

문제

During the past year, the UCF programming team members started a weekly dinner at Fujiyama Sushi. Usually, the programming team members wait for everyone to arrive to start eating, but as a wise programming team coach from the north of campus always says: “regionals is coming.” Heeding this ominous warning, the programming team members need to spend more time to prepare. To spend more time practicing, the programming team members will start eating as they arrive. However, they will still wait until everyone is done eating to leave Fujiyama.

Each car the team members are taking holds exactly four people. As each car may take a different amount of time to arrive at Fujiyama and each team member may have different eating speeds, it is important to assign team members to cars in a careful manner. Any team member can be assigned to any car as all team members can drive any of the cars.

Given the time it takes for cars to arrive and eating speeds of the team members, determine the minimum amount of time needed for all the team members to finish eating if the team members are assigned to cars optimally.

입력

The first input line contains a positive integer, n, indicating the number of trips to Fujiyama Sushi. Each trip is represented by three lines. The first line for each trip contains a single integer, c (1 ≤ c ≤ 50), representing the number of cars going to Fujiyama. The second line contains c integers, di (1 ≤ di ≤ 45), representing the time (in minutes) it takes for the i th car to arrive to Fujiyama. The third line contains 4*c integers, tj (1 ≤ tj ≤ 75), representing the time (in minutes) it takes for the j th team member to finish eating.

출력

For each trip, first output the heading “Trip #d: ”, where d is the trip number, starting with 1. Then, output a single integer representing the minimum amount of time (in minutes) for all the team members to finish eating. Follow the format illustrated in Sample Output.

예제1

  1. 예제 1

    입력
    3
    1
    40
    1 2 3 4
    2
    10 20
    5 6 3 4 8 9 1 2
    3
    15 20 20
    10 10 10 10 20 20 20 20 30 30 30 30
    
    예상 출력
    Trip #1: 44
    Trip #2: 24
    Trip #3: 45