[BOJ] 종이자르기

Date:

[BOJ] 종이자르기

Problem URL : 종이자르기

r, c = map(int, input().split())
m = int(input())
checkR = [0] * (r+1)
checkC = [0] * (c+1)
for i in range(m):
    rc, num = map(int, input().split())
    if rc == 0:
        checkC[num] = 1
    else:
        checkR[num] = 1

checkR[r] = 1
checkC[c] = 1

maxR = 0
cut = 0
for i in range(1, r+1):
    if checkR[i]:
        if i - cut > maxR:
            maxR = i - cut
        cut = i

maxC = 0
cut = 0
for i in range(1, c+1):
    if checkC[i]:
        if i - cut > maxC:
            maxC = i - cut
        cut = i

print(maxR * maxC)

댓글