문제 확인하기
2. 정답 코드 (Python, memory: 31120KB, time: 44ms)
width, height = map(int, input().split())
width_intervals = [0, width]
height_intervals = [0, height]
for _ in range(int(input())):
position, length = map(int, input().split())
if position == 0:
height_intervals.append(length)
else:
width_intervals.append(length)
width_intervals.sort()
height_intervals.sort()
max_square = 0
for i in range(1, len(width_intervals)):
for j in range(1, len(height_intervals)):
current_width = width_intervals[i] - width_intervals[i - 1]
current_height = height_intervals[j] - height_intervals[j - 1]
max_square = max(max_square, current_width * current_height)
print(max_square)