結果

問題 No.989 N×Mマス計算(K以上)
ユーザー 👑 KazunKazun
提出日時 2021-01-18 03:05:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 90,348 KB
最終ジャッジ日時 2023-08-20 09:02:46
合計ジャッジ時間 3,714 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,396 KB
testcase_01 AC 81 ms
71,484 KB
testcase_02 AC 82 ms
71,384 KB
testcase_03 AC 84 ms
71,412 KB
testcase_04 AC 83 ms
71,476 KB
testcase_05 AC 84 ms
71,608 KB
testcase_06 AC 85 ms
71,288 KB
testcase_07 AC 84 ms
71,396 KB
testcase_08 AC 83 ms
71,332 KB
testcase_09 AC 88 ms
71,404 KB
testcase_10 AC 153 ms
84,632 KB
testcase_11 AC 146 ms
88,584 KB
testcase_12 AC 150 ms
87,536 KB
testcase_13 AC 123 ms
85,796 KB
testcase_14 AC 169 ms
90,348 KB
testcase_15 AC 123 ms
78,860 KB
testcase_16 AC 132 ms
81,932 KB
testcase_17 AC 129 ms
85,496 KB
testcase_18 AC 125 ms
77,480 KB
testcase_19 AC 145 ms
89,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Binary_Search_Big_Count(A,x,equal=False,sort=False):
    """2分探索によって,xを超える要素の個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"を超える"がx"以上"になる
    """

    if sort:
        A.sort()

    if A[-1]<x or ((not equal) and A[-1]==x):
        return 0

    L,R=-1,len(A)-1
    while R-L>1:
        C=L+(R-L)//2
        if A[C]>x or (equal and A[C]==x):
            R=C
        else:
            L=C
    return len(A)-R
#================================================
import sys
input=sys.stdin.readline

N,M,K=map(int,input().split())

op,*B=input().split()
B=list(map(int,B))
B.sort()

X=0
for _ in range(N):
    a=int(input())
    if op=="+":
        X+=Binary_Search_Big_Count(B,K-a,True)
    else:
        X+=Binary_Search_Big_Count(B,(K+a-1)//a,True)
print(X)
0