結果
問題 | No.118 門松列(2) |
ユーザー |
![]() |
提出日時 | 2023-09-10 01:32:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 81 ms / 5,000 ms |
コード長 | 533 bytes |
コンパイル時間 | 666 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 84,992 KB |
最終ジャッジ日時 | 2024-06-27 17:39:48 |
合計ジャッジ時間 | 2,731 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
import sys, math input = lambda: sys.stdin.readline()[:-1] def MI(): return map(int, input().split()) inf = 10**18 mod = 10**9+7 from itertools import * def lcom(s): grouped = groupby(s) res = [] for k, v in grouped: res.append((k, int(len(list(v))))) return res n = int(input()) a = sorted(MI()) b = lcom(a) b1, b3 = 0, 0 for _, i in b: b3 += i b3 -= b[0][1] ans = 0 for b2 in range(1, len(b)): b1 += b[b2-1][1] b3 -= b[b2][1] ans += b[b2][1] * b1 * b3 % mod ans %= mod print(ans%mod)