結果
問題 | No.1282 Display Elements |
ユーザー | ayaoni |
提出日時 | 2020-11-06 21:58:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 289 ms / 2,000 ms |
コード長 | 1,342 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 86,936 KB |
実行使用メモリ | 171,372 KB |
最終ジャッジ日時 | 2023-09-29 18:42:53 |
合計ジャッジ時間 | 4,509 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 84 ms
79,124 KB |
testcase_01 | AC | 82 ms
78,816 KB |
testcase_02 | AC | 85 ms
79,196 KB |
testcase_03 | AC | 87 ms
79,076 KB |
testcase_04 | AC | 83 ms
79,028 KB |
testcase_05 | AC | 83 ms
79,108 KB |
testcase_06 | AC | 84 ms
79,188 KB |
testcase_07 | AC | 83 ms
78,812 KB |
testcase_08 | AC | 82 ms
78,964 KB |
testcase_09 | AC | 81 ms
79,116 KB |
testcase_10 | AC | 88 ms
79,608 KB |
testcase_11 | AC | 87 ms
79,392 KB |
testcase_12 | AC | 83 ms
78,916 KB |
testcase_13 | AC | 87 ms
78,824 KB |
testcase_14 | AC | 91 ms
79,896 KB |
testcase_15 | AC | 266 ms
163,548 KB |
testcase_16 | AC | 159 ms
107,676 KB |
testcase_17 | AC | 238 ms
144,812 KB |
testcase_18 | AC | 170 ms
106,252 KB |
testcase_19 | AC | 143 ms
101,544 KB |
testcase_20 | AC | 151 ms
101,416 KB |
testcase_21 | AC | 282 ms
170,980 KB |
testcase_22 | AC | 162 ms
101,468 KB |
testcase_23 | AC | 289 ms
171,372 KB |
ソースコード
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) class BIT: def __init__(self,init_value): self.n = len(init_value) self.tree = [0]*(self.n+1) for i in range(1,self.n+1): x = init_value[i-1] while i <= self.n: self.tree[i] += x i += i & (-i) def update(self,i,x): # i(1-index)番目の値を+x while i <= self.n: self.tree[i] += x i += i & (-i) return def query(self,i): # 1番目からi(1-index)番目までの和を返す res = 0 while i > 0: res += self.tree[i] i -= i & (-i) return res N = I() A = LI() A.sort() B = LI() X = list(set(A+B)) X.sort() M = len(X) d = {} for i in range(1,M+1): d[X[i-1]] = i bit = BIT([0]*200001) ans = 0 for i in range(N): b = B[i] bit.update(d[b],1) a = A[i] ans += bit.query(d[a]-1) print(ans)