logo AlgoBeat OnlineJudge
登录 注册

#213496. [GCJ 2011 #3] Dire Straights

内存限制:1024 MiB 时间限制:6000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are playing a card game, where each card has an integer number written on it.

To play the game, you are given some cards — your . Then you arrange the cards in your hand into . A straight is a set of cards with consecutive values; e.g. the three cards , or the single card . You then receive a number of dollars equal to the length of the shortest straight. If you have no cards, you can form no straights, so you get zero dollars.

You will be given a series of test cases, each of which describes the cards you will have in your hand. Find the maximum number of dollars you can receive for each test case.

输入格式

The first line of the input contains the number of test cases, . Each test case consists of one line. Each line contains , the number of cards in your hand, followed by integers giving the numbers on those cards. These numbers are all space-separated.

输出格式

For each test case, output one line containing "Case #: ", where is the case number (starting from 1) and is the maximum number of dollars you can receive.

样例

样例输入 1

4
10 1 2 3 4 5 10 9 8 7 6
8 101 102 103 104 105 106 103 104
0
5 1 2 3 4 9

样例输出 1

Case #1: 10
Case #2: 4
Case #3: 0
Case #4: 1

数据范围与提示

Sample Explanation

In case 1, you have ten cards numbered to , so you make one straight of length , and get dollars.

In case 2, you could make two straights and and get dollars. But it would be better to make and and get dollars.

In case 4, the card with the number must be in a straight containing only that card. So you get dollar.

In case 3, you have zero cards, so you get zero dollars. You don't get money for nothing.

Limits

  • The numbers on the cards are between and .

Small dataset (4 Pts, Test set 1 - Visible)

  • Time limit: 30 3 seconds.

Large dataset (12 Pts, Test set 2 - Hidden)

  • Time limit: 60 6 seconds.