結果
問題 | No.1282 Display Elements |
ユーザー |
👑 ![]() |
提出日時 | 2020-11-06 21:57:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 739 ms / 2,000 ms |
コード長 | 880 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 97,640 KB |
最終ジャッジ日時 | 2024-07-22 12:45:15 |
合計ジャッジ時間 | 5,864 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
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 0L,R=-1,len(A)-1while R-L>1:C=L+(R-L)//2if A[C]>x or (equal and A[C]==x):R=Celse:L=Creturn len(A)-R#================================================import sysfrom collections import dequeinput=sys.stdin.readlineN=int(input())A=list(map(int,input().split()))B=list(map(int,input().split()))A.sort()A=deque(A)X=0for i in range(N):X+=Binary_Search_Big_Count(A,B[i])_=A.popleft()print(X)