当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2511:The Top Shelf

Special Judge 特殊评判
题目描述
Dave Johnson is a book collector. Over the years, he collected so many books that he decided he needed to buy some new bookcases. He bought enough cases, of different quality, to fit all of his books. One problem remained, however. He wanted to put his favorite books in a special display on the top shelf of his best bookcase. This shelf is wide enough to fit at most 10 books.

This would normally be an easy task, but Dave is particular about the way he displays his favorite books. Not only must they be sorted alphabetically by title, but also there must never be two books next to each other that have the same letter in the same position in the title. Note that Dave looks only at alphabetical characters in the titles of his books, skipping spaces, apostrophes, etc., and he ignores the case of the letters. Thus, in the title "Portnoy's Complaint", 's' is the 8th character, and 'c' is the 9th character. As an example, "The Grapes Of Wrath" and "One Flew Over The Cuckoo's Nest" cannot be next to each other since the third letter of each title is the letter 'e'.

In order to help make this decision, Dave has assigned an emotional value to each of his books. Given a list of titles and the emotional value of each book, your job is to help Dave decide which books should go on his top shelf so as to maximize the total emotional value of all of the books.
输入解释
There will be one test case in each input file. The first line will contain an integer N (10 <= N <= 2500), specifying the number of books that are candidates for Dave's top shelf. The next N lines will each contain an integer E and a string S, separated by a single space. E is an integer no larger than 200 that represents the emotional value for Dave of the book with title S. Note that S can have an arbitrary number of spaces, but will not exceed 30 characters. S is guaranteed to contain at least one alphabetical character. Input should be read from stdin.
输出解释
The first line of the output should contain an integer M giving the number of books on Dave's top shelf. The second line should give the total emotional value of all of the books on the shelf. The next M lines should give the titles of the books on the shelf, in lexicographic order. If there is more than one solution, any one will do. Output should be written to stdout.
输入样例
12
117 The Pearl
42 L'Etranger
135 Hamlet
100 War And Peace
55 The Prince
175 Of Mice And Men
200 The Grapes Of Wrath
120 Ulysses
87 For Whom The Bell Tolls
10 Oliver Twist
50 Snow Crash
110 Great Expectations
输出样例
8
969
For Whom The Bell Tolls
Great Expectations
Hamlet
L'Etranger
Of Mice And Men
The Grapes Of Wrath
Ulysses
War And Peace

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2511

最后修改于 2020-10-29T06:34:31+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536