助手AI (CI翻译)
It's unbelievable, but an exam period has started at the OhWord University. It's even more unbelievable, that Valera got all the tests before the exam period for excellent work during the term. As now he's free, he wants to earn money by solving problems for his groupmates. He's made a $*list*$ of subjects that he can help with. Having spoken with $*n*$ of his groupmates, Valera found out the following information about them: what subject each of them passes, time of the exam and sum of money that each person is ready to pay for Valera's help.
难以置信,OhWord 大学的考试周开始了。更令人难以置信的是,Valera 因为学期中表现出色,在考试周开始前就拿到了所有考试题。现在他有空了,想通过帮同学解题来赚钱。他列出了一份自己能够提供帮助的科目清单。与 $*n*$ 位同学交谈后,Valera 了解到他们各自参加的考试科目、考试时间,以及愿意为他的帮助支付的金额。AI (CI翻译)
Having this data, Valera's decided to draw up a timetable, according to which he will solve problems for his groupmates. For sure, Valera can't solve problems round the clock, that's why he's found for himself an optimum order of day and plans to stick to it during the whole exam period. Valera assigned time segments for sleep, breakfast, lunch and dinner. The rest of the time he can work.
有了这些信息,Valera 决定制定一份日程安排,按计划为同学解题。当然,他不可能全天候工作,因此为自己安排了一个最合适的作息时间,并打算在整个考试周都遵守。他安排了睡觉、早餐、午餐和晚餐的时间,其余时间都可以工作。AI (CI翻译)
Obviously, Valera can help a student with some subject, only if this subject is on the $*list*$. It happened, that all the students, to whom Valera spoke, have different, but one-type problems, that's why Valera can solve any problem of subject $*list*_{*i*}$ in $*t*_{*i*}$ minutes.
显然,只有当某位同学的考试科目出现在 Valera 的清单上时,他才能帮助这位同学。恰好,所有与 Valera 交谈过的同学,题目类型各不相同,但都属于同一类,因此 Valera 解完清单中科目 $*list*_{*i*}$ 的任何一道题都需要 $*t*_{*i*}$ 分钟。AI (CI翻译)
Moreover, if Valera starts working at some problem, he can break off only for sleep or meals, but he can't start a new problem, not having finished the current one. Having solved the problem, Valera can send it instantly to the corresponding student via the Internet.
此外,Valera 一旦开始解某道题,只能在睡觉或用餐时中断;在完成当前题目之前,他不能开始解另一道题。解完题后,Valera 可以立即通过互联网将答案发送给对应的同学。AI (CI翻译)
If this student's exam hasn't started yet, he can make a crib, use it to pass the exam successfully, and pay Valera the promised sum. Since Valera has little time, he asks you to write a program that finds the order of solving problems, which can bring Valera maximum profit.
如果该同学的考试还没有开始,他就可以制作小抄并用它顺利通过考试,然后向 Valera 支付约定的金额。由于 Valera 的时间有限,他请你编写程序,找出解题顺序,使他的总收入最大。AI (CI翻译)
Input
输入格式
AI (CI翻译)The first line contains integers $*m*, *n*, *k*$ ($1 ≤ *m*, *n* ≤ 100$, $1 ≤ *k* ≤ 30$) — amount of subjects on the $*list*$, amount of Valera's potential employers and the duration of the exam period in days.
第一行包含整数 $*m*, *n*, *k*$ ($1 ≤ *m*, *n* ≤ 100$, $1 ≤ *k* ≤ 30$),分别表示清单中的科目数、Valera 的潜在雇主人数,以及考试周的天数。AI (CI翻译)
The following $*m*$ lines contain the names of subjects $*list*_{*i*}$ ($*list*_{*i*}$ is a non-empty string of at most 32 characters, consisting of lower case Latin letters). It's guaranteed that no two subjects are the same.
接下来 $*m*$ 行,每行包含一个科目名称 $*list*_{*i*}$($*list*_{*i*}$ 是一个长度不超过 32 的非空字符串,由小写拉丁字母组成)。保证没有两个科目相同。AI (CI翻译)
The $(*m* + 2)$-th line contains $*m*$ integers $*t*_{*i*}$ ($1 ≤ *t*_{*i*} ≤ 1000$) — time in minutes that Valera spends to solve problems of the $*i*$-th subject. Then follow four lines, containing time segments for sleep, breakfast, lunch and dinner correspondingly.
第 $(*m* + 2)$ 行包含 $*m*$ 个整数 $*t*_{*i*}$ ($1 ≤ *t*_{*i*} ≤ 1000$),表示 Valera 解清单中第 $*i*$ 个科目的题目所需的分钟数。接下来四行依次给出睡觉、早餐、午餐和晚餐的时间段。AI (CI翻译)
Each line is in format H1:M1-H2:M2, where $00 ≤$ H1, H2 $≤ 23$, $00 ≤$ M1, M2 $≤ 59$. Time H1:M1 stands for the first minute of some Valera's action, and time H2:M2 stands for the last minute of this action. No two time segments cross. It's guaranteed that Valera goes to bed before midnight, gets up earlier than he has breakfast, finishes his breakfast before lunch, finishes his lunch before dinner, and finishes his dinner before midnight. All these actions last less than a day, but not less than one minute. Time of the beginning and time of the ending of each action are within one and the same day. But it's possible that Valera has no time for solving problems.
每行的格式为 H1:M1-H2:M2,其中 $00 ≤$ H1、H2 $≤ 23$,$00 ≤$ M1、M2 $≤ 59$。时间 H1:M1 表示 Valera 某项活动的第一分钟,时间 H2:M2 表示该活动的最后一分钟。任意两个时间段都不会重叠。保证 Valera 在午夜前上床,起床时间早于早餐时间,早餐结束时间早于午餐时间,午餐结束时间早于晚餐时间,晚餐结束时间早于午夜。所有这些活动的时长都小于一天且不少于一分钟。每项活动的开始和结束时间都在同一天内。不过,Valera 可能完全没有时间解题。AI (CI翻译)
Then follow $*n*$ lines, each containing the description of students. For each student the following is known: his exam subject $*s*_{*i*}$ ($*s*_{*i*}$ is a non-empty string of at most 32 characters, consisting of lower case Latin letters), index of the exam day $*d*_{*i*}$ ($1 ≤ *d*_{*i*} ≤ *k*$), the exam time $*time*_{*i*}$, and sum of money $*c*_{*i*}$ ($0 ≤ *c*_{*i*} ≤ 10^{6}$, $*c*_{*i*}$ — integer) that he's ready to pay for Valera's help. Exam time $*time*_{*i*}$ is in the format HH:MM, where $00 ≤$ HH $≤ 23$, $00 ≤$ MM $≤ 59$. Valera will get money, if he finishes to solve the problem strictly before the corresponding student's exam begins.
接下来 $*n*$ 行,每行描述一位同学,包含其考试科目 $*s*_{*i*}$($*s*_{*i*}$ 是一个长度不超过 32 的非空字符串,由小写拉丁字母组成)、考试日期的编号 $*d*_{*i*}$ ($1 ≤ *d*_{*i*} ≤ *k*$)、考试时间 $*time*_{*i*}$,以及他愿意为 Valera 的帮助支付的金额 $*c*_{*i*}$ ($0 ≤ *c*_{*i*} ≤ 10^{6}$,$*c*_{*i*}$ 为整数)。考试时间 $*time*_{*i*}$ 的格式为 HH:MM,其中 $00 ≤$ HH $≤ 23$,$00 ≤$ MM $≤ 59$。只有当 Valera 严格早于对应同学的考试开始时间完成解题时,他才能获得报酬。AI (CI翻译)
Output
输出格式
AI (CI翻译)In the first line output the maximum profit that Valera can get. The second line should contain number $*p*$ — amount of problems that Valera is to solve. In the following $*p*$ lines output the order of solving problems in chronological order in the following format: index of a student, to whom Valera is to help; index of the time, when Valera should start the problem; time, when Valera should start the problem (the first minute of his work); index of the day, when Valera should finish the problem; time, when Valera should finish the problem (the last minute of his work). To understand the output format better, study the sample tests.
第一行输出 Valera 能获得的最大收入。第二行输出整数 $*p*$,表示 Valera 要解的题目数量。接下来 $*p*$ 行按时间顺序输出解题安排,格式如下:同学的编号(Valera 将帮助该同学)、开始解题日期的编号、开始解题时间(工作的第一分钟)、完成解题日期的编号、完成解题时间(工作的最后一分钟)。请参考样例以更好地理解输出格式。AI (CI翻译)
样例
3 3 4
calculus
algebra
history
58 23 15
00:00-08:15
08:20-08:35
09:30-10:25
19:00-19:45
calculus 1 09:36 100
english 4 21:15 5000
history 1 19:50 50
150
2
1 1 08:16 1 09:29
3 1 10:26 1 10:40
2 2 1
matan
codeforces
1 2
00:00-08:00
09:00-09:00
12:00-12:00
18:00-18:00
codeforces 1 08:04 2
matan 1 08:02 1
3
2
2 1 08:01 1 08:01
1 1 08:02 1 08:03
2 2 1
matan
codeforces
2 2
00:00-08:00
09:00-09:00
12:00-12:00
18:00-18:00
codeforces 1 08:04 2
matan 1 08:03 1
2
1
1 1 08:01 1 08:02
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。