#abc354g. G - Select Strings
G - Select Strings
Score : points
问题陈述
给定 个字符串 ,它们由小写英文字母组成,以及 个正整数 。
如果集合 是 的一个子集,并且对于 中的任意两个不同的元素 , 不是 的子串,则称 为一个好集合。
找出一个好集合 的 的最大可能值。
什么是子串?字符串 的一个子串是通过从 的开头删除零个或多个字符,以及从 的结尾删除零个或多个字符得到的字符串。例如,ab
是 abc
的一个子串,但 ac
不是 abc
的子串。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given strings consisting of lowercase English letters and positive integers .
A subset of is called a good set if there is no pair such that is a substring of .
Find the maximum possible value of for a good set .
What is a substring? A substring of a string is a string obtained by deleting zero or more characters from the beginning and zero or more characters from the end of . For example, ab
is a substring of abc
, but ac
is not a substring of abc
.
Constraints
- is a string consisting of lowercase English letters.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
atcoder
at
coder
code
5 2 3 4
Sample Output 1
6
The possible good sets and their corresponding are as follows:
- :
- :
- :
- :
- :
- :
The maximum among them is , so print .
Sample Input 2
10
abcd
abc
ab
a
b
c
d
ab
bc
cd
100 10 50 30 60 90 80 70 40 20
Sample Output 2
260