2016 Feb Bronze Problem 3 Load Balancing
Jump to navigation
Jump to search
Official Problem Statement
Problem
Solution
import sys
sys.stdin = open("balancing.in", "r") sys.stdout = open("balancing.out", "w")
n,b = map(int,input().split())
x_val = [] y_val = [] x_fen = [] h_fen = []
for _ in range(n): x, y = map(int,input().split()) x_val.append(x) y_val.append(y) x_fen.append(x + 1) h_fen.append(x + 1)
min_balance = n
for v_y in x_fen: for h_x in h_fen:
tl,tr,bl,br = 0,0,0,0 for k in range(n): x,y = x_val[k],y_val[k] if x > h_x and y > v_y: tl+=1 elif x < h_x and y > v_y: tr+=1 elif x > h_x and y < v_y: bl+=1 else: br+=1
min_balance = min(min_balance, max(tl,tr,bl,br))
print(min_balance)