結果

問題 No.945 YKC饅頭
ユーザー maspy
提出日時 2020-03-07 03:31:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,233 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 55,424 KB
最終ジャッジ日時 2024-10-14 11:08:22
合計ジャッジ時間 23,932 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 74
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop, heappush

# %%
N, M = map(int, readline().split())
L_to_IRT = [[] for _ in range(N+1)]
for i in range(M):
    L, R, T = readline().decode().split()
    L = int(L)
    R = int(R)
    L_to_IRT[L].append((i,R,T))


# %%
q = []
Y = 0
K = 0
C = 0
for L, IRT in enumerate(L_to_IRT):
    for x in IRT:
        heappush(q, x)
    while q and q[0][1] < L:
        heappop(q)
    if not q:
        continue
    x = q[0][2]
    if x == 'Y':
        Y += 1
    elif x == 'K':
        K += 1
    else:
        C += 1


# %%
print(Y,K,C)
0