Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

PASCAL 1AC 1PE

Posted by aiouniya at 2012-08-29 05:40:03 on Problem 1484
var 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator