Posted on 2008-04-13 09:50
superman 阅读(300)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1195 C++ 00:00.00 844K */
2 #include <iostream>
3
4 using namespace std;
5
6 int main()
7 {
8 int n, m, fuse, sequence = 0;
9 while((cin >> n >> m >> fuse) && n && m && fuse)
10 {
11 sequence++;
12 cout << "Sequence " << sequence << endl;
13
14 int c[21] = {0};
15 for(int i = 1; i <= n; i++)
16 cin >> c[i];
17
18 int cnt = 0, max = 0, t;
19 bool state[21] = {false}, blown = false;
20 for(int i = 0; i < m; i++)
21 {
22 cin >> t;
23 if(blown)
24 continue;
25
26 state[t] ^= 1;
27 max >?= cnt += (state[t] ? c[t] : -c[t]);
28
29 if(cnt > fuse)
30 {
31 blown = true;
32 cout << "Fuse was blown." << endl;
33 }
34 }
35 if(blown == false)
36 cout << "Fuse was not blown." << endl
37 << "Maximal power consumption was " << max << " amperes." << endl;
38 cout << endl;
39 }
40
41 return 0;
42 }
43