結果
問題 | No.1282 Display Elements |
ユーザー | Coki628 |
提出日時 | 2020-12-16 10:26:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 893 ms / 2,000 ms |
コード長 | 1,881 bytes |
コンパイル時間 | 1,291 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 203,648 KB |
最終ジャッジ日時 | 2023-10-20 09:07:14 |
合計ジャッジ時間 | 8,826 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
55,728 KB |
testcase_01 | AC | 42 ms
55,728 KB |
testcase_02 | AC | 42 ms
55,728 KB |
testcase_03 | AC | 43 ms
55,728 KB |
testcase_04 | AC | 43 ms
55,728 KB |
testcase_05 | AC | 43 ms
55,728 KB |
testcase_06 | AC | 43 ms
55,728 KB |
testcase_07 | AC | 43 ms
55,728 KB |
testcase_08 | AC | 43 ms
55,728 KB |
testcase_09 | AC | 43 ms
55,728 KB |
testcase_10 | AC | 58 ms
66,640 KB |
testcase_11 | AC | 57 ms
66,648 KB |
testcase_12 | AC | 51 ms
61,920 KB |
testcase_13 | AC | 59 ms
66,400 KB |
testcase_14 | AC | 63 ms
68,972 KB |
testcase_15 | AC | 811 ms
203,648 KB |
testcase_16 | AC | 330 ms
132,964 KB |
testcase_17 | AC | 672 ms
167,052 KB |
testcase_18 | AC | 417 ms
142,616 KB |
testcase_19 | AC | 186 ms
97,628 KB |
testcase_20 | AC | 185 ms
98,236 KB |
testcase_21 | AC | 893 ms
201,028 KB |
testcase_22 | AC | 188 ms
98,112 KB |
testcase_23 | AC | 887 ms
201,036 KB |
ソースコード
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10**9) INF = 10**19 MOD = 10**9 + 7 EPS = 10**-10 class BIT: """ Binary Indexed Tree """ def __init__(self, n): from collections import defaultdict self.n = n # 0-indexed n += 1 nv = 1 while nv < n: nv *= 2 self.size = nv self.tree = defaultdict(int) def sum(self, i): """ [0, i]を合計する """ s = 0 i += 1 while i > 0: s += self.tree[i-1] i -= i & -i return s def add(self, i, x): """ 値の追加:添字i, 値x """ i += 1 while i <= self.size: self.tree[i-1] += x i += i & -i def query(self, l, r): """ 区間和の取得 [l, r) """ return self.sum(r-1) - self.sum(l-1) def get(self, i): """ 一点取得 """ return self.query(i, i+1) def update(self, i, x): """ 値の更新:添字i, 値x """ self.add(i, x - self.get(i)) def print(self): for i in range(self.n): print(self.get(i), end=' ') print() N = INT() A = LIST() B = LIST() A.sort() bit = BIT(max(A+B)) ans = 0 for i in range(N): bit.add(B[i], 1) ans += bit.query(0, A[i]) print(ans)