This page is still under construction.

Parts of this page are still being built. What you see may change.

Citystar

Interview

Time limit1sMemory limit128 MB

Summary
For each street, find the five house numbers whose span (max minus min plus 1) is smallest, breaking ties by the smallest house numbers.
Level

Medium6 of 10

Topics
Sorting, Sliding window, Two pointers, Array
Solved
No attempts yet

Problem

On the planet Citystar the cities look somewhat like stars. There is a small round city center from which straight streets radiate outward. People living on the same street feel a bond with one another, while different streets share a friendly rivalry. The planet holds programming contests in which each street enters one team. The organizers want to suggest good team members to each street and, to stay unbiased, they ask an alien (you) for help.

Each street has houses on only one side, numbered 1,2,3,…1, 2, 3, \dots starting from the city center. Every house is the same size, and each house holds at most one programmer (they simply cannot live together). For each street you are given the house numbers of its programmers.

A team can practice more often the closer its members live to one another, so you want the smallest range of houses that still covers five programmers (three regular members, one substitute, and one coach). The range is defined as (largest house number) −- (smallest house number) +1+ 1. For example, choosing house numbers 65,71,64,61,8165, 71, 64, 61, 81 gives a range of 81−61+1=2181 - 61 + 1 = 21.

If several teams share the same smallest range, choose the one that lives closest to the city center (where the contest takes place), that is, the one with the smaller house numbers.

Input

The first line contains the number of scenarios. Each scenario describes one street on a single line. The line begins with the number of programmers on that street, kk (5≤k≤100 0005 \le k \le 100\,000), followed by one house number for each programmer (each house number is between 11 and 10 000 00010\,000\,000 and the numbers on a street are distinct).

Output

For each scenario, first print a line Scenario #i:, where ii is the scenario number starting at 11. On the next line describe the chosen team: print the range first, then the five chosen house numbers in increasing order, each preceded by a single space. Separate the outputs of consecutive scenarios with a single blank line.

Examples1

  1. Example 1

    Input
    2
    10 65 2 71 123 7 45 64 4 61 81
    16 111 103 117 105 102 113 119 107 11 3 17 5 2 13 19 7
    
    Expected output
    Scenario #1:
    21: 61 64 65 71 81
    
    Scenario #2:
    10: 2 3 5 7 11