Logo
(追記) (追記ここまで)

26345번 - Rummy Score 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB18151184.615%

문제

Mack and Zack (Dr. Orooji’s twins) play Rummy with a modified deck of playing cards. The card values are 1 through 13 (1 does not serve the dual purpose of 1 and 14; it is only 1) and there are no suits. Also, a deck may contain any number of each card value (unlike a standard deck of cards which has exactly four of each).

Given the seven cards in a Rummy hand (held by Mack or Zack), you are to determine the points lost by the hand. In Rummy, you group three (or more) cards together if they have the same value or they have consecutive values. Examples of a group include {4, 4, 4}, {6, 6, 6, 6, 6}, {9, 10, 11}, and {1, 2, 3, 4}. The “points lost by a hand” is the sum of values for cards that are not in a group.

When computing the points lost by a hand, you group the cards to minimize the loss, i.e., you want the smallest total sum of values for the ungrouped cards. Note that a given card could possibly belong to more than one group; you need to pick the group that minimizes the total points lost. For example, given the seven cards {2, 2, 2, 3, 4, 8, 10}, the grouping {2, 3, 4} is better than the grouping {2, 2, 2}. Note also that a card can be used in only one group, e.g., from the Rummy hand {2, 2, 2, 3, 4, 8, 10}, we can not create the two groups {2, 2, 2} and {2, 3, 4} since there are not a total of four cards with a value of 2 in the hand.

입력

The first input line contains only a positive integer, n, indicating the number of Rummy hands. The hands are on the following n input lines, one set per line. Each set contains seven integers, each integer between 1 and 13, inclusive (the values are separated by a single space).

출력

At the beginning of each test case, output “Rummy Hand: v” where v is the input values. Then, on the next output line, print the points lost by the hand. Leave a blank line after the output for each test case. Follow the format illustrated in Sample Output.

제한

예제 입력 1

7
5 2 2 6 2 10 4
11 11 11 11 1 2 3
11 2 3 4 5 13 1
4 5 6 6 6 6 13
2 2 2 3 4 8 10
12 13 1 4 4 4 4
10 10 10 8 9 8 9

예제 출력 1

Rummy Hand: 5 2 2 6 2 10 4
10
Rummy Hand: 11 11 11 11 1 2 3
0
Rummy Hand: 11 2 3 4 5 13 1
24
Rummy Hand: 4 5 6 6 6 6 13
13
Rummy Hand: 2 2 2 3 4 8 10
22
Rummy Hand: 12 13 1 4 4 4 4
26
Rummy Hand: 10 10 10 8 9 8 9
10

힌트

출처

University > University of Central Florida > 2012 Local Programming Contest 8번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /