-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathZOJ1195(AC).cpp
81 lines (70 loc) · 942 Bytes
/
ZOJ1195(AC).cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
int main()
{
int i;
int n;
int m;
int c;
int d[30];
int s[30];
int p;
int blow;
int maxp;
int t;
int cc;
cc = 0;
while(scanf("%d%d%d", &n, &m, &c) == 3)
{
if(n == 0 && m == 0 && c == 0)
{
break;
}
for(i = 0; i < n; i++)
{
scanf("%d", &d[i]);
}
for(i = 0; i < n; i++)
{
s[i] = 0;
}
p = 0;
maxp = 0;
blow = 0;
for(i = 0; i < m; i++)
{
scanf("%d", &t);
if(s[t - 1] == 0)
{
p = p + d[t - 1];
if(p > maxp)
{
maxp = p;
}
if(p > c)
{
blow = 1;
}
}
else
{
p = p - d[t - 1];
}
s[t - 1] = !s[t - 1];
}
printf("Sequence %d\n", cc + 1);
if(blow == 1)
{
printf("Fuse was blown.\n");
}
else
{
printf("Fuse was not blown.\n");
printf("Maximal power consumption was %d amperes.\n", maxp);
}
printf("\n");
cc++;
}
return 0;
}