結果
問題 |
No.2422 regisys?
|
ユーザー |
|
提出日時 | 2025-08-18 21:09:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 751 ms / 2,000 ms |
コード長 | 1,449 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 82,900 KB |
実行使用メモリ | 140,724 KB |
最終ジャッジ日時 | 2025-08-18 21:09:28 |
合計ジャッジ時間 | 25,247 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 61 |
ソースコード
import os,sys,random,threading from random import randint,choice,shuffle from copy import deepcopy from io import BytesIO,IOBase from types import GeneratorType from functools import lru_cache,reduce from bisect import bisect_left,bisect_right from collections import Counter,defaultdict,deque from itertools import accumulate,combinations,permutations from heapq import heapify,heappop,heappush from typing import Generic,Iterable,Iterator,TypeVar,Union,List from string import ascii_lowercase,ascii_uppercase,digits from math import ceil,floor,sqrt,pi,factorial,gcd,log,log10,log2,inf from decimal import Decimal,getcontext from sys import stdin, stdout, setrecursionlimit input = lambda: sys.stdin.readline().rstrip("\r\n") MI = lambda :map(int,input().split()) li = lambda :list(MI()) ii = lambda :int(input()) mod = int(1e9 + 7) inf = 1<<60 py = lambda :print("YES") pn = lambda :print("NO") n,m=li() a=li() b=li() idx=list(range(n)) idx.sort(key=lambda x:-a[x]) c0=[] c1=[] for _ in range(m): t,c=li() if t==0: c0.append(c) else: c1.append(c) c0.sort() c1.sort() h=[] for i in c0: while idx and a[idx[-1]]<=i: j=idx.pop() heappush(h,-b[j]) if h: heappop(h) h=[-i for i in h] for i in idx: h.append(b[i]) h.sort(reverse=True) cnt=0 for i in c1: while h and h[-1]<=i: h.pop() cnt+=1 if cnt>0: cnt-=1 print(len(h)+cnt)