시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 3 | 1 | 1 | 33.333% |
Tired of being teased by the other farm animals for their poor vocabulary, Farmer John's cows have stolen a word game from FJ's house to use for practice. In this particular word game, each cow receives a set of N (1 ≤ N ≤ 100) not necessarily unique uppercase letters (for example: 'V', 'B', 'O', 'E', 'I', 'N', 'O'). Each letter has a certain specified point value, and each cow's goal is to form a valid word using a subset of her letters worth the maximum number of points. For example, if every letter is worth 1 point, the maximum number of points one can receive from the letters above is 6, using the word 'BOVINE'.
The cows have also managed to steal a dictionary containing M (1 ≤ M ≤ 10,000) words from FJ's house, so they can check whether or not certain words are valid. Please help his cows compute the best possible words they can form based on the letters they receive.
5 4 1 1 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 D C O R W WORD COW COURT ROW
12
All letters are worth 1 point except 'C', which is worth 10 points. We receive the letters 'D', 'C', 'O', 'R', and 'W'.
The word 'COW' is worth 12 points, and we can form it using a subset of the letters in our input.