結果

問題 No.2956 Substitute with Average
ユーザー ArcAki
提出日時 2024-11-09 03:09:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 85,376 KB
最終ジャッジ日時 2024-11-09 03:09:42
合計ジャッジ時間 3,410 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
from random import randint
from collections import deque, defaultdict as dd
from copy import deepcopy
input = stdin.readline
MOD = 998244353
INF = 1 << 60
xor = randint(100, INF)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = n*(n+1)//2+1
    pre = a[0]
    cnt = 0
    for i in range(n):
        if pre==a[i]:
            cnt += 1
        else:
            ans -= cnt*(cnt+1)//2
            pre = a[i]
            cnt = 1
    ans -= cnt*(cnt+1)//2
    print(ans)


if __name__ == "__main__":
    main()
0