結果
| 問題 |
No.118 門松列(2)
|
| コンテスト | |
| ユーザー |
threepipes_s
|
| 提出日時 | 2016-01-03 19:43:06 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 5,000 ms |
| コード長 | 324 bytes |
| コンパイル時間 | 100 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 17,112 KB |
| 最終ジャッジ日時 | 2024-10-09 07:20:27 |
| 合計ジャッジ時間 | 2,196 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
from collections import Counter
m = 1000000007;
n = int(input())
a = dict(Counter(list(map(int, input().split()))))
dp = [0,0,0]
for d in a:
newdp = [a[d],0,0]
for i in range(3):
newdp[i] = (newdp[i]+dp[i])%m
for i in range(1, 3):
newdp[i] = (newdp[i]+dp[i-1]*a[d])%m
dp = newdp
print(dp[2])
threepipes_s