結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー mkawa2mkawa2
提出日時 2020-05-23 10:47:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,671 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 46,896 KB
最終ジャッジ日時 2024-04-16 16:50:26
合計ジャッジ時間 9,898 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 482 ms
46,716 KB
testcase_01 AC 488 ms
46,316 KB
testcase_02 AC 34 ms
11,008 KB
testcase_03 AC 34 ms
11,008 KB
testcase_04 AC 34 ms
11,008 KB
testcase_05 AC 34 ms
11,136 KB
testcase_06 AC 34 ms
11,008 KB
testcase_07 AC 34 ms
11,008 KB
testcase_08 WA -
testcase_09 AC 33 ms
11,136 KB
testcase_10 AC 33 ms
11,008 KB
testcase_11 AC 34 ms
11,008 KB
testcase_12 AC 495 ms
46,896 KB
testcase_13 AC 589 ms
46,432 KB
testcase_14 AC 548 ms
46,072 KB
testcase_15 WA -
testcase_16 AC 523 ms
45,292 KB
testcase_17 AC 484 ms
46,212 KB
testcase_18 AC 535 ms
44,968 KB
testcase_19 AC 558 ms
46,092 KB
testcase_20 AC 482 ms
46,308 KB
testcase_21 AC 561 ms
44,788 KB
testcase_22 AC 491 ms
46,412 KB
testcase_23 AC 33 ms
11,008 KB
testcase_24 AC 34 ms
11,008 KB
testcase_25 AC 33 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from operator import itemgetter
import sys
from heapq import *

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
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 SI(): return sys.stdin.readline()[:-1]

def main():
    inf=10**9
    n,m=MI()
    abx=defaultdict(list)
    bax=defaultdict(list)
    cnt2=cnt3=0
    bb=set()
    for _ in range(n):
        x,a,b=MI()
        if x>=3:cnt3+=1
        else:
            abx[a].append((b,x))
            bax[b].append((a,x))
            bb.add(b)
        if x==2:cnt3+=1
        if x==1:cnt2+=1
    bb=list(sorted(bb))

    hp0=[]
    hp12=[]
    hp10=[]
    hp2=[]
    ans=cnt3
    sb=inf
    for a,bx in sorted(abx.items()):
        sa=a
        for b,x in bx:
            if x==2 and b<sb:heappush(hp2,-b);cnt2+=1;cnt3-=1
            if x==1 and b<sb:heappush(hp10,-b);cnt2-=1
        while hp0 and hp0[0]<=sa:heappop(hp0);cnt2-=1
        while hp12 and hp12[0]<=sa:heappop(hp12);cnt3-=1;cnt2+=1

        while bb and cnt2+cnt3<m:
            sb=bb.pop()
            for a,x in bax[sb]:
                if x==0 and a>sa:heappush(hp0,a);cnt2+=1
                if x==1 and a>sa:heappush(hp12,a);cnt2-=1;cnt3+=1
            while hp2 and -hp2[0]>=sb:heappop(hp2);cnt3+=1;cnt2-=1
            while hp10 and -hp10[0]>=sb:heappop(hp10);cnt2+=1
        #print(cnt2,cnt3,hp0,hp10,hp12,hp2)
        if cnt2+cnt3<m:break

        ans=min(ans,cnt3)

    print(ans)

main()
0