TopCoder SRM 614: MinimumSquareEasy
解法については TopCoder SRM614 解説 を参考にしてください。
public class MinimumSquareEasy { public long minArea(int[] x, int[] y) { int n = x.Length; long minSide = long.MaxValue; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { var xs = new List<int>(); var ys = new List<int>(); for (int k = 0; k < n; k++) { if (i == k || j == k) continue; xs.Add(x[k]); ys.Add(y[k]); } var side = Math.Max(xs.Max() - xs.Min(), ys.Max() - ys.Min()) + 2; minSide = Math.Min(minSide, side); } } return minSide * minSide; } }