编程介的小学生 2017-08-08 05:58 采纳率: 20.5%
浏览 715
已采纳

Hang Up the System

You're going to design a multi-task operating system for an embedded system. Because the resources are limited on this mini computer, parallel running of some programs will probably give rise to the deadlock problem. According to experience, you have a list of programs that will hang up the system if all of them are running simultaneously. You are also given the priority of these programs. Now you're interested in the maximum value of the total priority of the programs that can run simultaneously in the system without hanging up.

Input

The input has several test cases, each starts with n (2 <= n <= 16), the number of programs. The following n lines contain the name of the program and its priority, with each program on a line. The name is a string of no more than 10 characters. The priority is an integer from 1 to 100. The next line contains a single integer m (0 <= m <= 1,024), which is the length of the list of the conflicting programs. The following m lines each contains several names of the programs which cannot run together.

The input is terminated with a case n = 0. This case should not be processed.

Output

Print the case number and the maximal total priority value you can get on a line. Adhere to the sample output format.

Sample Input

3
HARDDISK 20
FLOPPY 10
CDROM 15
1
CDROM HARDDISK
5
HARDDISK 20
FLOPPY 10
CDROM 15
SERIAL 25
MOUSE 20
3
CDROM HARDDISK FLOPPY
FLOPPY SERIAL
SERIAL MOUSE
0

Sample Output

System 1: 30
System 2: 60

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题