• [1494] blow or not

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • There are N devices, marked from 1 to n, and the power of ith device is x. There is only one fuse, that means if you use too much devices, the fuse will blow out. At first all devices are closed. Now you get M operations, each operation makes a change to one device, if it is closed, it will open, if it is open, it will close.

  • 输入
  • There are multiply test cases.
    The first line contains three integers N M and C. (N <=20 M <= 30), C means the fuse rating. Next there are N lines, one number per line, the ith line tells the power of ith device. Then there are M lines, one number K per line, indecates changing the state of Kth device. Input ends with 0 0 0.
  • 输出
  • For each test case, output the test case number. If the fuse was blown, output "Fuse was blown.", or you should output "Fuse was not blown." first, then output the maximum sum of power when opening or closing devices. See Sample for more details, output a blank line after each test case.
  • 样例输入
  • 2 2 10
    5
    7
    1
    2
    3 6 10
    2
    5
    7
    2
    1
    2
    3
    1
    3
    0 0 0
    
  • 样例输出
  • Case 1
    Fuse was blown.
    
    Case 2
    Fuse was not blown.
    Maximal power consumption was 9 amperes.
    
    
  • 提示
  • 来源
  • Mr.Cai
  • 操作

显示春菜