結果

問題 No.1282 Display Elements
ユーザー 👑 KazunKazun
提出日時 2020-11-06 21:57:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 629 ms / 2,000 ms
コード長 880 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 108,216 KB
最終ジャッジ日時 2023-09-29 18:41:27
合計ジャッジ時間 6,864 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,392 KB
testcase_01 AC 89 ms
71,416 KB
testcase_02 AC 90 ms
71,644 KB
testcase_03 AC 88 ms
71,760 KB
testcase_04 AC 89 ms
71,720 KB
testcase_05 AC 88 ms
71,644 KB
testcase_06 AC 90 ms
71,420 KB
testcase_07 AC 89 ms
71,784 KB
testcase_08 AC 92 ms
71,928 KB
testcase_09 AC 94 ms
71,640 KB
testcase_10 AC 95 ms
77,048 KB
testcase_11 AC 95 ms
77,064 KB
testcase_12 AC 91 ms
71,612 KB
testcase_13 AC 100 ms
76,616 KB
testcase_14 AC 99 ms
77,532 KB
testcase_15 AC 562 ms
107,832 KB
testcase_16 AC 231 ms
86,904 KB
testcase_17 AC 436 ms
101,236 KB
testcase_18 AC 274 ms
90,244 KB
testcase_19 AC 144 ms
107,816 KB
testcase_20 AC 288 ms
108,004 KB
testcase_21 AC 621 ms
108,216 KB
testcase_22 AC 622 ms
108,140 KB
testcase_23 AC 629 ms
108,112 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
from collections import deque

input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

A.sort()
A=deque(A)

X=0
for i in range(N):
    X+=Binary_Search_Big_Count(A,B[i])
    _=A.popleft()
print(X)
0