結果
問題 |
No.1623 三角形の制作
|
ユーザー |
![]() |
提出日時 | 2021-07-24 09:45:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,281 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 612,900 KB |
最終ジャッジ日時 | 2024-07-19 10:29:45 |
合計ジャッジ時間 | 4,045 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | MLE * 1 -- * 18 |
ソースコード
from collections import deque class BinaryIndexedTree: def __init__(self, size): self._data = [0] * size def add(self, i, x): data = self._data i += 1 n = len(data) while i <= n: data[i - 1] += x i += i & -i def _sum(self, stop): data = self._data result = 0 i = stop while i > 0: result += data[i - 1] i -= i & -i return result def range_sum(self, start, stop): return self._sum(stop) - self._sum(start) n = int(input()) r = list(map(int, input().split())) g = list(map(int, input().split())) b = list(map(int, input().split())) rr = [0] * 3001 for i in r: rr[i] += 1 gg = [0] * 3001 for i in g: gg[i] += 1 bb = [0] * 3001 for i in b: bb[i] += 1 gb = [] for i in range(1, 3001): x = gg[i] if x == 0: continue for j in range(1, 3001): y = gg[j] if y == 0: continue gb.append((max(i, j), i + j, x * y)) gb = deque(sorted(gb)) bit = BinaryIndexedTree(6001) result = 0 for i in range(1, 3001): while len(gb) != 0 and gb[0][0] <= i: _, x, y = gb.popleft() bit.add(x, y) result += rr[i] * bit.range_sum(i + 1, 6001) print(result)