#Lutece1300. Easy Problem
Easy Problem
Migrated from Lutece 1300 Easy Problem
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Given strings , Each string has a non-negative
cost .
Let’s define the function of string :
represents the number of occurrences of in
Find the maximal value of function over all strings.
Note that is not necessary to be some string from , and its length must be greater than zero.
Input
The first line is , denoting the number of strings,containing only a
to z
.
Then lines each line is a string .
Then a line contains integers .
The sum of length of all the string will no more than
Output
Output one line representing the maximal value.
Samples
3
abc
abcd
cdab
1 2 3
6
Note
Let be ab
, then the value will be , it’s the maximal value.
Resources
The 14th UESTC Programming Contest Preliminary