Advertisement
Guest User

Другие костыли

a guest
May 20th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.47 KB | None | 0 0
  1. var delta, x, y, z: integer;
  2. sum, n, i: longint;
  3. begin
  4. delta:=maxint; sum:=0;
  5. readln(n);
  6. for i:=1 to n do begin
  7.     readln(x,y);
  8.     if y>x then begin
  9.        z := x;
  10.        x := y;
  11.        y := z;
  12.     end;
  13.     sum := sum + x;
  14.     if (x - y < delta) and ((x - y) mod 3 <> 0) then delta := x-y;
  15. end;
  16. if sum mod 3 <> 0 then writeln(sum)
  17. else if delta < maxint then begin
  18.      if (sum - delta) mod 3 <> 0 then writeln(sum-delta);
  19.      end
  20.      else writeln(0)
  21. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement