ACM 广东04省赛 - Helpful papers

来源:百度知道 编辑:UC知道 时间:2024/05/22 03:15:03
Problem
How time flies! Sunshine, an intelligent girl, becomes a senior student now. Recently, she is preparing for her thesis. She made a plan to read many papers, because only in this way can she master the research trends in her interesting field and form her own ideas.
Now Sunshine has downloaded many papers. Every paper has only one author, and maybe some of them were written by the same person. Sunshine wants to read each author’s paper according to the time these papers were written.
For example, Sunshine has five papers: P1 (written by A in 1981), P2 (written by B in 1982), P3 (written by A in 1986), P4 (written by B in 1989), P5 (written by A in 1999).
Sunshine should read P1 before reading P3, P3 before reading P5, and P2 before reading P4. So all the possibility of the schedules are list here:
P1->P3->P5->P2->P4 P1->P3->P2->P5->P4
P1->P2->P3->P5->P4 P2->P1->P3->P5->P4
P1-&g

问题
如何光阴似箭!阳光,一个智能的女孩,成为一名学生了。最近,她正在准备她的论文。她提出一个计划,多读报纸,因为只有这样,才能掌握她在她的研究趋势有趣的领域和形式她自己的想法。
现在,阳光已下载许多文件。每个文件只有一个作者,也许其中一些人写的是同一个人。阳光希望阅读每个作者? ?造纸根据时间的推移,这些文件的书面。
例如,阳光有五个文件:小一(所写的在1981年) ,为P2 (书面的B于1982年) ,第3页(所写的在1986年) ,小(书面的B于1989年) ,小五(撰写的在1999年) 。
阳光应读小一前读小三,小三在读小五,和P2在阅读的P4 。因此,所有的可能性都在此处列出的时间表:
小一“小三, ”小五, “二, ”小四至小一“小三, ”二, “的p5 ”的P4
小一“的P2 , ”小三, “小五, ”小二, “小一”小三, “的p5 ”的P4
小一“小三, ”二, “的P4 - ”小五小一“的P2 , ”小三, “的P4 - ”小五
二, “小一”小三, “的P4 - ”小五小一“的P2 - ”的P4 - “小三, ”小五
二, “小一”的P4 - “小三- ”小五的P2 - “的P4 - ”小一“小三- ”小五
什么? ?何况,每个文件有两个参数(无线,钛) 。 TI是时间阅读文件和Wi是一个增值被用来代表的重要性,该文件。现在阳光请你给她一个时间表县费用( s )是最小的。
对于时间表小(小一,二, ? ? ,光合速率) ,
成本(县) =韩元*表# t1 + W2号* (表# t1 +氚) + W3号* (表# t1 +时刻+的T3 )+??+下午* (表# t1 +时刻+ ? ? +田纳西州) 。

输入
的第一行输入一个正整数ç这是一些测试案例之后。每个测试案例包括两部分。
第一行的第一部分是一个积极的整数n ( 0 “ ñ ” = 100 )它代表了一些文件。在此之后,氮线得到遵守。随着行的包含两个正整数的Wi ( 0 “无线” = 100 ) ,钛( 0 “钛” = 100 )为随着文件。
第一行中的第二