Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 392 Bytes

20207.md

File metadata and controls

30 lines (23 loc) · 392 Bytes

20207

Python

import sys

input = sys.stdin.readline

N = int(input())
lst = [list(map(int, input().split())) for _ in range(N)]

_MAX = 365
dp = [0] * (_MAX+2)
for s, e in lst:
    for i in range(s, e+1):
        dp[i] += 1

ans = 0
h, w = 0, 0
for v in dp:
    if v == 0:
        ans += h * w
        h = w = 0
    else:
        h = max(h, v)
        w += 1
print(ans)