結果

問題 No.945 YKC饅頭
ユーザー mkawa2
提出日時 2019-12-12 09:43:07
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,891 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 79,372 KB
最終ジャッジ日時 2024-06-24 19:30:20
合計ジャッジ時間 33,844 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 74
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n, m = MI()
    to = defaultdict(list)
    ttomark = {"Y": 0, "K": 1, "C": 2}
    for p in range(m):
        l, r, t = input().split()
        l, r = int(l) - 1, int(r) - 1
        to[l].append([p, r, ttomark[t]])
    hp = []
    ans = [0] * 3
    for i in range(n):
        for prm in to[i]:
            heappush(hp, prm)
        while hp and hp[0][1] < i: heappop(hp)
        if not hp:continue
        ans[hp[0][2]] += 1
    print(*ans)

main()
0