V_CIIC_D - Cards

no tags 

Beto is playing cards with Xavier, Dickie and Charlie, Luis, as usual, is the dealer, then, he deals M cards to each player, then, he puts N cards flipped up on the table and S cards flipped up below the other ones, now, each player can play as many cards they have in their hands as long as the kind of the card is shown in the S cards flipped up, at the same time, the kind chosen must appear in at least one of the kinds shown in the first N cards flipped up.

 

The player must choose only one kind of his all hand and play it along, the game continues as this, The player puts his card on the table, and then he sums to his/her count i*j where i is the number of the placed card (starting from 1) and j is the number of the card (from 1 to 9), you are ask to maximize the sum of the result and show the kind that must be played to achieve this score, in case of tie, break the tie by choosing the lexicographically smallest kind.

 

INPUT DETAILS:

The input starts with three integers N,M,S, each of one denoting, respectively, the length of a string S1, the cards in the hand of Beto and the length of a string S2. Then, M lines will follow, each of one will denote the description of the cards in the hand of Beto, every line will contain two characters X and Y, the first one will denote the value of the card (from 1 to 9) and the second character will contain the kind of the card (from A to Z).

 

OUTPUT DETAILS:

You must print a character and an integer, the character must be the best kind for the selected combination and the integer must be the best selected combo of the cards. The character and the integer must be separated by a single space.

 

 

INPUT

OUTPUT

4 5 2

DCHS

9H

3C

4S

1D

3S

HS

S 11

 

CONSTRAINTS:

1 <= N <= 26

1 <= M <= 10000

1 <= S <= N

 


hide comments
Meghna: 2013-07-12 23:49:31

Whts with the HS?

Karshit Kumar: 2013-05-19 05:29:13

This is my first problem to start with, but I suppose there is something wrong with the Input description and input??
Pardon me if I am wrong... p)

Last edit: 2013-05-19 05:29:27

Added by:Venezuelan Programming League
Date:2013-02-16
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64