結果

問題 No.945 YKC饅頭
ユーザー LyricalMaestro
提出日時 2025-05-04 02:55:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,195 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 163,988 KB
最終ジャッジ日時 2025-05-04 02:56:00
合計ジャッジ時間 22,449 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 74
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/945
import heapq


def main():
    N, M = map(int, input().split())
    lrt = []
    for _ in range(M):
        l, r,t  = input().split()
        lrt.append((int(l) - 1, int(r) - 1, t))
    
    l_map = [[] for _ in range(N)]
    for index in range(M):
        l, r, t = lrt[index]
        l_map[l].append((index, r, t))
    

    answers = ["" for _ in range(N)]
    queue = []
    for l in range(N):
        for index, r, t in l_map[l]:
            heapq.heappush(queue, (index, r, t))
        
        while len(queue) > 0 and queue[0][1] < l:
            heapq.heappop(queue)
        
        if len(queue) > 0:
            _, _, t = queue[0]
            answers[l] = t

    
    answers_map = {"Y": 0, "K": 0, "C": 0}
    for l in range(N):
        k = answers[l]
        if k in answers_map:
            answers_map[k] += 1

    print(answers_map["Y"], answers_map["K"], answers_map["C"])


    





                





    
        















if __name__ == "__main__":
    main()
0