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 |
一直runtime error求助各位 ,帮忙看看,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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator