8446: Video Game

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

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 S_i 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?

贝茜正在玩电子游戏!


游戏中共有三个有效按钮 A,B,C


贝茜可以按自己喜欢的任何顺序按下按钮。


但是,游戏中有 N 个不同的组合技。


其中组合技 i 可以用一个字符串 Si 来表示,其长度在 1 15 之间,并且只包含字母 A,B,C


每当贝茜按出一个组合技时,都能因此获得一分。


组合技可能会相互重叠,甚至可能同时完成!


例如,如果 N=3 并且三个组合技为 ABA,CB,ABACB,而贝茜按下了 ABACB,则她将获得 3 分。


贝茜可以多次按下同一组合技多次得分。


贝茜希望自己能够获得尽可能高的分数。


如果她恰好按了 K 次按钮,那么她可以获得的最大积分是多少。


输入格式

第一行包含两个整数 N K


接下来 N 行,每行包含一个字符串表示 Si




输入格式

第一行包含两个整数 N K


接下来 N 行,每行包含一个字符串表示 Si

输出格式

输出贝茜能够获得的最大分数。

输入样例 复制

3 7
ABA
CB
ABACB

输出样例 复制

4

数据范围与提示

1N20,

1K1000

最佳按键顺序为 ABACBCB,可获得 4 分,1 分来自 ABA1 分来自 ABACB2 分来自 CB