Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var delta, x, y, z: integer;
- sum, n, i: longint;
- begin
- delta:=maxint; sum:=0;
- readln(n);
- for i:=1 to n do begin
- readln(x,y);
- if y>x then begin
- z := x;
- x := y;
- y := z;
- end;
- sum := sum + x;
- if (x - y < delta) and ((x - y) mod 3 <> 0) then delta := x-y;
- end;
- if sum mod 3 <> 0 then writeln(sum)
- else if delta < maxint then begin
- if (sum - delta) mod 3 <> 0 then writeln(sum-delta);
- end
- else writeln(0)
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement