📄 problem 1195.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0047)http://acm.zju.edu.cn/show_problem.php?pid=1195 -->
<HTML><HEAD><TITLE>Problem 1195</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY>
<CENTER><IMG src="Problem 1195.files/logo.gif" align=center></IMG></CENTER>
<HR>
<CENTER><FONT color=blue size=+2>Blowing Fuses</FONT></CENTER>
<HR>
<CENTER><FONT color=green>Time limit:</FONT> 1 Seconds <FONT
color=green>Memory limit: </FONT>32768K </FONT><BR><FONT
color=green>Total Submit:</FONT> 2653 <FONT color=green>Accepted
Submit:</FONT> 821 </CENTER>
<HR>
Maybe you are familiar with the following situation. You have plugged in a lot
of electrical devices, such as toasters, refrigerators, microwave ovens,
computers, stereos, etc, and have them all running. But at the moment when you
turn on the TV, the fuse blows, since the power drawn from all the machines is
greater than the capacity of the fuse. Of course this is a great safety feature,
avoiding that houses burn down too often due to fires ignited by overheating
wires. But it is also annoying to walk down to the basement (or some other
inconvenient place) to replace to fuse or switch it back on.
<P></P>
<P>What one would like to have is a program that checks before turning on an
electrical device whether the combined power drawn by all running devices
exceeds the fuses capacity (and it blows), or whether it is safe to turn it on.
</P>
<P><BR><B>Input</B><BR><BR>The input consists of several test cases. Each test
case describes a set of electrical devices and gives a sequence of turn on/off
operations for these devices. </P>
<P>The first line of each test case contains three integers n, m and c, where n
is the number of devices (n <= 20), m the number of operations performed on
these devices and c is the capacity of the fuse (in Amperes). The following n
lines contain one positive integer ci each, the consumption (in Amperes) of the
i-th device. </P>
<P></P>
<P>This is followed by m lines also containing one integer each, between 1 and n
inclusive. They describe a sequence of turn on/turn off operations performed on
the devices. For every number, the state of that particular devices is toggled,
i.e. if it is currently running, it is turned off, and if it is currently turned
off, it will by switched on. At the beginning all devices are turned off. </P>
<P></P>
<P>The input will be terminated by a test case starting with n = m = c = 0. This
test case should not be processed. </P>
<P><BR><B>Output</B><BR><BR>For each test case, first output the number of the
test case. Then output whether the fuse was blown during the operation sequence.
The fuse will be blown if the sum of the power consumptions ci of turned on
devices at some point exceeds the capacity of the fuse c. </P>
<P>If the fuse is not blown, output the maximal power consumption by turned on
devices that occurred during the sequence. </P>
<P></P>
<P>Output a blank line after each test case. </P>
<P><BR><B>Sample Input </B></P>
<P>2 2 10<BR>5<BR>7<BR>1<BR>2<BR>3 6
10<BR>2<BR>5<BR>7<BR>2<BR>1<BR>2<BR>3<BR>1<BR>3<BR>0 0 0</P>
<P><BR><B>Sample Output</B><BR><BR>Sequence 1<BR>Fuse was blown.</P>
<P>Sequence 2<BR>Fuse was not blown.<BR>Maximal power consumption was 9
amperes.<BR></P>
<HR>
<FONT color=green size=+1>Problem Source: </FONT><I>Southwestern Europe 1998</I>
<HR>
<CENTER><A href="http://acm.zju.edu.cn/submit.php?pid=1195">Submit</A>
<A href="http://acm.zju.edu.cn/list_problem.php?vol=2">Back</A>
<A
href="http://acm.zju.edu.cn/problem_status.php?pid=1195">Status</A> </CENTER>
<HR>
<CENTER>
<TABLE width="100%" border=0>
<TBODY>
<TR>
<TD align=right width="65%"><A href="http://acm.zju.edu.cn/"><FONT
color=red>Zhejiang University Online Judge</FONT></A> <A
href="http://acm.zju.edu.cn/"><FONT color=red>V1.0</FONT></A></TD>
<TD align=right width="35%"><A href="http://www.zzhang.cn/"><FONT
color=#ffffff
size=-3>Book</FONT></A></TD></TR></TBODY></TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -