Sticks
시간 제한3초메모리 제한512 MB
막대기 12개의 길이가 주어질 때 각 막대기를 최대 한 번씩 사용해 만들 수 있는 삼각형의 최대 개수를 구하고 그 구성을 출력한다.
문제
Bob has 12 sticks of lengths l1, l2, . . . , l12. He wants to use some sticks to form triangles as many as possible. Each triangle can be built by three different sticks la, lb, lc such that la + lb > lc, la + lc > lb and lb + lc > la. If each stick can be used for at most one triangle, how many triangles can he build at most? Also, could you please find a way to build them all?
입력
The input contains several test cases. The first line contains an integer T indicating the number of test cases. The following describes all test cases. For each test case:
The only line contains twelve integers l1, l2, . . . , l12.
출력
For each test case, firstly output a line containing “Case #x: m” (without quotes), where x is the test case number starting from 1, and m is the maximum number of triangles that can be built.
Then, output m lines, each line of which contains three integers, representing three side lengths of a triangle.
If there are many optimal solutions, please output any of them. Note that every stick for each test case can be used at most once, and every two adjacent integers in a line of the output should be separated by one space.
제한
- 1 ≤ T ≤ 6000
- 1 ≤ l1, l2, . . . , l12 ≤ 109