Created
March 24, 2026 08:54
-
-
Save maehrm/34e874f4a9ba24ea2907d0afc0883a90 to your computer and use it in GitHub Desktop.
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
| import bisect | |
| N = int(input()) | |
| WH = [list(map(int, input().split())) for _ in range(N)] | |
| WH.sort(key=lambda x: (x[0], -x[1])) | |
| lis = [] | |
| H = [h for _, h in WH] | |
| for h in H: | |
| idx = bisect.bisect_left(lis, h) | |
| if idx == len(lis): | |
| lis.append(h) | |
| else: | |
| lis[idx] = h | |
| print(len(lis)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment