結果

問題 No.568 じゃんじゃん 落とす 委員会
コンテスト
ユーザー Ryoma Ishii
提出日時 2024-01-16 02:43:23
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 406 ms / 1,000 ms
コード長 725 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 270 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 101,012 KB
最終ジャッジ日時 2026-04-14 19:29:35
合計ジャッジ時間 9,900 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,M=map(int,input().split())
W=10**5+10
C=[0,0,0,0,0,0]
A=[[] for i in range(W)]
B=[[] for i in range(W)]
Student=[]

for i in range(N):
    x,a,b=map(int,input().split())
    Student.append(x+1)
    A[a].append(i)
    B[b].append(i)
    C[x+1]+=1
#print(C)   
SA=0
SB=W
ans=W
while True:
    if SA>=W:
        break
    #print(SA,SB,C)
    if sum(C[2:])>=M and sum(C[3:])<ans:
        ans=sum(C[3:])
    
    for ids in A[SA]:
        C[Student[ids]]-=1
        Student[ids]-=1
        C[Student[ids]]+=1
    SA+=1
    
    while SB>0 and sum(C[2:])<M:
        #print(C,sum(C[2:]),M)
        SB-=1
        for ids in B[SB]:
            C[Student[ids]]-=1
            Student[ids]+=1
            C[Student[ids]]+=1
print(ans)
0