编程介的小学生 2017-08-19 02:09 采纳率: 20.5%
浏览 682
已采纳

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

  • 写回答

1条回答

  • threenewbee 2017-08-29 15:59
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀