====== 겹치는 선분 ====== ===== 풀이 ===== * [[ps:problems:boj:11000]]과 같은 유형. 풀이는 그쪽 참고. ===== 코드 ===== """Solution code for "BOJ 1689. 겹치는 선분". - Problem link: https://www.acmicpc.net/problem/1689 - Solution link: http://www.teferi.net/ps/problems/boj/1689 Tags: [Sweeping] """ import sys RIGHT = 0 LEFT = 1 def main(): N = int(sys.stdin.readline()) coord = [] for _ in range(N): s, e = [int(x) for x in sys.stdin.readline().split()] coord.append((s, LEFT)) coord.append((e, RIGHT)) count = 0 answer = max( (count := count + (1 if type_ == LEFT else -1)) for _, type_ in sorted(coord) ) print(answer) if __name__ == '__main__': main() {{tag>BOJ ps:problems:boj:골드_4}}