結果

問題 No.1282 Display Elements
ユーザー 👑 platinumplatinum
提出日時 2020-09-04 13:02:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 525 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 36,884 KB
最終ジャッジ日時 2024-05-06 20:12:54
合計ジャッジ時間 6,556 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 RE -
testcase_04 AC 30 ms
10,752 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 33 ms
10,880 KB
testcase_11 AC 33 ms
10,880 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 34 ms
11,008 KB
testcase_15 AC 784 ms
35,228 KB
testcase_16 RE -
testcase_17 AC 637 ms
27,536 KB
testcase_18 RE -
testcase_19 AC 478 ms
26,348 KB
testcase_20 AC 494 ms
25,688 KB
testcase_21 RE -
testcase_22 AC 523 ms
25,688 KB
testcase_23 AC 824 ms
36,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect

N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

c = a + b
c = list(set(c))
c.sort()

for i in range(N):
    a[i] = bisect.bisect_left(c, a[i])
    b[i] = bisect.bisect_left(c, b[i])

siz = 2 * N
ft = [0] * siz

def add(k, x):
    while(k <= siz):
        ft[k] += x
        k += k & -k
def get(k):
    res = 0
    while k:
        res += ft[k]
        k -= k & -k
    return res

a.sort()
ans = 0
for i in range(N):
    add(b[i] + 1, 1)
    ans += get(a[i])

print(ans)
0