結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー Ryoma Ishii
提出日時 2024-01-16 02:43:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 404 ms / 1,000 ms
コード長 725 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 95,888 KB
最終ジャッジ日時 2024-09-28 02:26:07
合計ジャッジ時間 7,448 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

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