| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
PASCAL 1AC 1PEvar a,b:array[1..100]of integer;
i,t,num,n,m,c,sum,tmp,max:integer;
begin
readln(n,m,c);
num:=1;
while (n<>0)and(m<>0)and(c<>0) do begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
sum:=0;
t:=0;
max:=0;
for i:=1 to n do read(a[i]);
for i:=1 to m do begin
read(tmp);
inc(b[tmp]);
if odd(b[tmp]) then t:=t+a[tmp]
else t:=t-a[tmp];
if t>max then max:=t;
end;
for i:=1 to n do
if odd(b[i]) then sum:=sum+a[i];
writeln('Sequence ',num);
if sum>c then writeln('Fuse was blown.')
else begin writeln('Fuse was not blown.');
writeln('Maximal power consumption was ',max,' amperes.');
end;
readln(n,m,c);
writeln;
inc(num);
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator