結果
問題 | No.989 N×Mマス計算(K以上) |
ユーザー |
👑 ![]() |
提出日時 | 2021-01-18 03:05:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 124 ms / 2,000 ms |
コード長 | 918 bytes |
コンパイル時間 | 295 ms |
コンパイル使用メモリ | 81,588 KB |
実行使用メモリ | 89,656 KB |
最終ジャッジ日時 | 2024-11-30 10:31:32 |
合計ジャッジ時間 | 2,382 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
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)