結果

問題 No.118 門松列(2)
ユーザー もちふわゆるゆるもちふわゆるゆる
提出日時 2023-09-10 01:31:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 89,932 KB
最終ジャッジ日時 2023-09-10 01:31:50
合計ジャッジ時間 4,465 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
76,088 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 74 ms
71,572 KB
testcase_07 AC 75 ms
71,384 KB
testcase_08 AC 75 ms
71,076 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = list(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)
0