結果

問題 No.3128 Isosceles Triangle
ユーザー K2
提出日時 2025-04-25 22:23:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,009 ms / 2,500 ms
コード長 467 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,524 KB
実行使用メモリ 178,664 KB
最終ジャッジ日時 2025-04-25 22:23:25
合計ジャッジ時間 11,436 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0