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

一直runtime error求助各位 ,帮忙看看,

Posted by jackland at 2007-08-29 10:25:39 on Problem 2181
Program pku2181;

 const
        fin = 'data2.in';
        fout= '';
 
 Var
        
        A               : Array [1..15010] of Longint;
        n               : Longint;

Procedure Init;
begin

  Assign( input , fin ); reset( input );
  Assign( output , fout ); rewrite( output ); 
end;

Procedure Work;
 var
        i,now,ans       : Longint;
begin
  readln(N);
  For i:=1 to n do
  begin
    readln(A[i]);
  end;
  now:=1;
  i:=1;
  ans:=0;
  repeat
   if odd( now ) then
   begin
     while (i < n ) and not(A[i+1] < A[i])  do
     inc(i);
     inc(ans , A[i]);
   end else
   begin
     while (i < n ) and not(A[i+1] > A[i])  do
     inc(i);
     if i<>n then  dec(ans , A[i]);
   end;
   inc(now);
   inc(i)
  until i>n;
  writeln(Ans);
end;

Procedure Finish;
begin
  close( input );
  close( output );
end;

Begin
  Init;
  Work;
  Finish;
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