21561_VideoGameCombos

2022-5-16 18:19| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505641578900-Problem List-采集的数据-后羿采集器.html

Pro.ID

21561

Title

Video Game Combos

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21561

AC

2

Submit

7

Ratio

28.57%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Bessie is playing a video game! In the game, the three letters 'A', 'B', and 'C' are the only valid buttons. Bessie may press the buttons in any order she likes; however, there are only N distinct combos possible (1 ≤ N ≤ 20). Combo i is represented as a string Si which has a length between 1 and 15 and contains only the letters 'A', 'B', and 'C'.

    Whenever Bessie presses a combination of letters that matches with a combo, she gets one point for the combo. Combos may overlap with each other or even finish at the same time! For example if N = 3 and the three possible combos are "ABA", "CB", and "ABACB", and Bessie presses "ABACB", she will end with 3 points. Bessie may score points for a single combo more than once.

    Bessie of course wants to earn points as quickly as possible. If she presses exactly K buttons (1 ≤ K ≤ 1,000), what is the maximum number of points she can earn?

    输入

    * Line 1: Two space-separated integers: N and K.

    * Lines 2..N+1: Line i+1 contains only the string Si, representing combo i.

    输出

    Description

    Bessie is playing a video game! In the game, the three letters 'A', 'B', and 'C' are the only valid buttons. Bessie may press the buttons in any order she likes; however, there are only N distinct combos possible (1 ≤ N ≤ 20). Combo i is represented as a string Si which has a length between 1 and 15 and contains only the letters 'A', 'B', and 'C'.

    Whenever Bessie presses a combination of letters that matches with a combo, she gets one point for the combo. Combos may overlap with each other or even finish at the same time! For example if N = 3 and the three possible combos are "ABA", "CB", and "ABACB", and Bessie presses "ABACB", she will end with 3 points. Bessie may score points for a single combo more than once.

    Bessie of course wants to earn points as quickly as possible. If she presses exactly K buttons (1 ≤ K ≤ 1,000), what is the maximum number of points she can earn?

    Input

    * Line 1: Two space-separated integers: N and K.

    * Lines 2..N+1: Line i+1 contains only the string Si, representing combo i.

    Output

    * Line 1: A single integer, the maximum number of points Bessie can obtain.

    Sample Input

    3 7
    ABA
    CB
    ABACB

    Sample Output

    4

    Hint

    OUTPUT DETAILS:

    The optimal sequence of buttons in this case is ABACBCB, which gives 4 points--1 from ABA, 1 from ABACB, and 2 from CB.

    Source

    样例输入

    3 7
    ABA
    CB
    ABACB

    样例输出

    4

    提示

    OUTPUT DETAILS:

    The optimal sequence of buttons in this case is ABACBCB, which gives 4 points--1 from ABA, 1 from ABACB, and 2 from CB.


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部