結果
問題 | No.1703 Much Matching |
ユーザー |
![]() |
提出日時 | 2021-10-08 22:15:23 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,299 bytes |
コンパイル時間 | 263 ms |
コンパイル使用メモリ | 82,364 KB |
実行使用メモリ | 238,676 KB |
最終ジャッジ日時 | 2024-07-23 04:44:21 |
合計ジャッジ時間 | 27,488 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 TLE * 2 -- * 1 |
ソースコード
import bisect import copy import decimal import fractions import functools import heapq import itertools import math import random import sys from collections import Counter,deque,defaultdict from functools import lru_cache,reduce from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max def _heappush_max(heap,item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappushpop_max(heap, item): if heap and item < heap[0]: item, heap[0] = heap[0], item heapq._siftup_max(heap, 0) return item from math import gcd as GCD read=sys.stdin.read readline=sys.stdin.readline readlines=sys.stdin.readlines def LIS(lst,weakly=False,max_value=float('inf')): f=bisect.bisect_right if weakly else bisect.bisect_left N=len(lst) update=[None]*N dp=[max_value]*N for k,x in enumerate(lst): i=f(dp,x) dp[i]=x update[k]=(i,dp[i]) n=bisect.bisect_left(dp,max_value) lis=[None]*n n-=1 for i,x in update[::-1]: if i==n: lis[n]=x n-=1 return lis N,M,Q=map(int,readline().split()) AB=[] for _ in range(Q): a,b=map(int,readline().split()) AB.append((a,b)) AB.sort(key=lambda tpl:(tpl[0],-tpl[1])) B=[b for a,b in AB] ans=len(LIS(B)) print(ans)