結果
| 問題 | No.3128 Isosceles Triangle |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-25 22:23:08 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 702 ms / 2,500 ms |
| コード長 | 467 bytes |
| 記録 | |
| コンパイル時間 | 218 ms |
| コンパイル使用メモリ | 96,108 KB |
| 実行使用メモリ | 171,184 KB |
| 最終ジャッジ日時 | 2026-07-10 07:18:07 |
| 合計ジャッジ時間 | 9,591 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
N = int(input())
A = list(map(int, input().split()))
from collections import defaultdict
from bisect import bisect_left
d = defaultdict(int)
for i in range(N):
d[A[i]] += 1
cnt = sorted(list(d.items()))
S = [0] * (len(cnt) + 1)
for i in range(len(cnt)):
S[i+1] = S[i] + cnt[i][1] * (cnt[i][1] - 1) // 2
ans = 0
for i in range(len(cnt)):
ans += cnt[i][1] * (S[-1] - S[bisect_left(cnt, (cnt[i][0]//2+1,))] - cnt[i][1] * (cnt[i][1] - 1) // 2)
print(ans)