|
|
back to boardWhy WA? type digit=0..9; const max=500001; var sz:array[1..max]of byte; n,s:longint; procedure add(k:longint;m:digit); var t:longint; begin t:=(n-k+2)div 2; if odd(n-k)then sz[t]:=sz[t]+m*10 else sz[t]:=sz[t]+m; end; procedure main; var t:longint; a,b:digit; e:longint; begin fillchar(sz,sizeof(sz),0); readln(n); for t:=1 to n do begin readln(a,b); add(t,a+b); end; for t:=1 to (n+1)div 2 do while sz[t]>=100 do begin dec(sz[t],100); inc(sz[t+1]); end; s:=(n+1)div 2+1; while (sz[s]=0)and(s>0) do dec(s); for t:=s downto 1 do begin a:=sz[t]div 10; b:=sz[t]mod 10; if a<>0 then write(a) else if t<>s then write(a); write(b); end; if s=0 then write(0); end; begin main; end. |
|
|