ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1048. Superlong Sums

Why 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 (+)
Posted by Dmitry 'Diman_YES' Kovalioff 7 Aug 2003 20:07
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.