Skip to content

Instantly share code, notes, and snippets.

@dniku
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save dniku/c7b012d5f835ffd80728 to your computer and use it in GitHub Desktop.

Select an option

Save dniku/c7b012d5f835ffd80728 to your computer and use it in GitHub Desktop.
Problem H from VK wild-card round #1. The language is Picat.
import cp.
main =>
N = read_int(),
X = new_array(N),
Y = new_array(N),
foreach(I in 1..N)
X[I] := read_int(),
Y[I] := read_int()
end,
BestArea = 50000,
foreach(A in 2..4)
foreach(B in 2..4)
Above := false,
foreach(I in 1..N)
Diff := Y[I] * A + B * X[I] - A * B,
if Diff then
Above := true
end
% Above := Above || (Y[I] * A + B * X[I] - A * B > 0)
end,
if (not Above) && (A * B < BestArea) then
BestArea := A * B,
printf("upd %d %d\n", A, B)
end
end
end,
writeln(BestArea / 2).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment