Created
March 24, 2026 12:36
-
-
Save maehrm/2739a92d7a4222deeb1b87f7256d0aac to your computer and use it in GitHub Desktop.
D - Online games https://atcoder.jp/contests/abc221/tasks/abc221_d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import defaultdict | |
| N = int(input()) | |
| events = defaultdict(int) | |
| for _ in range(N): | |
| A, B = map(int, input().split()) | |
| events[A] += 1 | |
| events[A + B] -= 1 | |
| days = sorted(events.keys()) | |
| num = defaultdict(int) | |
| curr = 0 # 現在の人数 | |
| for i in range(len(days) - 1): | |
| now = days[i] | |
| nxt = days[i + 1] | |
| curr += events[now] | |
| period = nxt - now | |
| if curr > 0: | |
| num[curr] += period # 現在の人数が続いた日数 | |
| ans = [0] * (N + 1) | |
| for k, v in num.items(): | |
| ans[k] = v | |
| print(*ans[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment