結果
問題 | No.3128 Isosceles Triangle |
ユーザー |
|
提出日時 | 2025-03-06 01:13:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 369 ms / 2,500 ms |
コード長 | 488 bytes |
コンパイル時間 | 625 ms |
コンパイル使用メモリ | 82,220 KB |
実行使用メモリ | 187,416 KB |
最終ジャッジ日時 | 2025-03-06 01:13:37 |
合計ジャッジ時間 | 8,540 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
n = int(input()) a = [int(x) for x in input().split()] assert 3 <= n <= 3 * 10 ** 5 for x in a: assert 1 <= x <= 10 ** 9 from collections import defaultdict cnt = defaultdict(int) for x in a: cnt[x] += 1 a = list(sorted(set(a))) ans = 0 s = 0 for c in cnt.values(): s += c * (c - 1) // 2 ans -= c * c * (c - 1) // 2 idx = 0 for x in a: while a[idx] * 2 <= x: c = cnt[a[idx]] s -= c * (c - 1) // 2 idx += 1 ans += s * cnt[x] print(ans)