結果

問題 No.2796 Small Matryoshka
ユーザー titia
提出日時 2024-07-30 08:22:20
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 685 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 53,308 KB
最終ジャッジ日時 2024-07-30 08:22:28
合計ジャッジ時間 7,154 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from operator import itemgetter
from heapq import heappop,heappush

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

AB.sort(key=itemgetter(0))
H=[]

for a,b in AB:
    if H:
        if H[0]<=a:
            heappop(H)
            heappush(H,b)
        else:
            heappush(H,b)
    else:
        heappush(H,b)

print(len(H)-1)
0