結果

問題 No.945 YKC饅頭
ユーザー LyricalMaestro
提出日時 2025-05-04 02:53:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,031 bytes
コンパイル時間 1,415 ms
コンパイル使用メモリ 81,936 KB
実行使用メモリ 163,880 KB
最終ジャッジ日時 2025-05-04 02:53:53
合計ジャッジ時間 23,944 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 65
権限があれば一括ダウンロードができます

ソースコード

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, "M": 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["M"], answers_map["C"])


    





                





    
        















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