結果

問題 No.1703 Much Matching
ユーザー vwxyzvwxyz
提出日時 2021-10-08 23:35:09
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,810 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 47,488 KB
最終ジャッジ日時 2023-09-30 13:46:55
合計ジャッジ時間 13,047 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,968 KB
testcase_01 AC 17 ms
8,048 KB
testcase_02 AC 18 ms
8,020 KB
testcase_03 AC 53 ms
10,424 KB
testcase_04 AC 41 ms
9,612 KB
testcase_05 AC 92 ms
12,536 KB
testcase_06 AC 490 ms
19,768 KB
testcase_07 AC 41 ms
8,736 KB
testcase_08 AC 598 ms
22,892 KB
testcase_09 AC 644 ms
21,508 KB
testcase_10 AC 105 ms
10,868 KB
testcase_11 AC 180 ms
12,872 KB
testcase_12 AC 43 ms
9,072 KB
testcase_13 AC 254 ms
13,116 KB
testcase_14 AC 24 ms
8,480 KB
testcase_15 AC 191 ms
14,624 KB
testcase_16 AC 313 ms
14,308 KB
testcase_17 AC 378 ms
12,980 KB
testcase_18 AC 21 ms
8,304 KB
testcase_19 AC 819 ms
23,772 KB
testcase_20 AC 98 ms
10,412 KB
testcase_21 AC 935 ms
26,408 KB
testcase_22 AC 442 ms
19,244 KB
testcase_23 AC 297 ms
13,544 KB
testcase_24 AC 22 ms
8,576 KB
testcase_25 AC 66 ms
10,164 KB
testcase_26 AC 254 ms
16,100 KB
testcase_27 AC 393 ms
13,112 KB
testcase_28 AC 831 ms
27,508 KB
testcase_29 AC 199 ms
13,632 KB
testcase_30 AC 255 ms
14,372 KB
testcase_31 AC 54 ms
9,600 KB
testcase_32 AC 447 ms
19,356 KB
testcase_33 AC 354 ms
18,148 KB
testcase_34 AC 40 ms
8,708 KB
testcase_35 AC 95 ms
10,056 KB
testcase_36 AC 1,810 ms
47,488 KB
testcase_37 AC 156 ms
16,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import sys
readline=sys.stdin.readline

def LIS(lst,weakly=False,max_value=float('inf')):
    f=bisect.bisect_right if weakly else bisect.bisect_left
    dp=[max_value]*(min(N,M)+1)
    for x in lst:
        i=f(dp,x)
        dp[i]=x
    n=bisect.bisect_left(dp,max_value)
    return n

N,M,Q=map(int,readline().split())
AB=[[0]*M for i in range(N)]
for _ in range(Q):
    a,b=map(int,readline().split())
    a-=1
    b-=1
    AB[a][b]=1
lst=[]
for a in range(N):
    for b in range(M-1,-1,-1):
        if AB[a][b]:
            lst.append(b)
inf=1<<30
ans=LIS(lst,max_value=inf)
print(ans)
0