|
|
back to boardWhy I got WA? Posted by tancy 7 Aug 2003 15:44 const maxn=1000000; var i,n:integer; data:array[1..maxn]of integer; Procedure Init; var a,b:integer; begin readln(n); for i:=1 to n do begin readln(a,b); data[i]:=a+b; end; end; Procedure Main; begin for i:=n downto 1 do begin inc(data[i-1],data[i] div 10); data[i]:=data[i] mod 10; end; if data[1]>=10 then begin write(data[1] div 10);data[1]:=data[1] mod 10; end; for i:=1 to n do write(data[i]); end; begin Init; Main; end. Bad idea (+) I haven't looked into your program to find the reason of WA, but you use array of 2 mb. size - don't you think it is going to be MLE anyway? BTW, there is a way to solve this problem without any arrays at all. |
|
|