結果
問題 | No.2956 Substitute with Average |
ユーザー |
|
提出日時 | 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 |
ソースコード
from sys import stdinfrom random import randintfrom collections import deque, defaultdict as ddfrom copy import deepcopyinput = stdin.readlineMOD = 998244353INF = 1 << 60xor = randint(100, INF)def main():n = int(input())a = list(map(int, input().split()))ans = n*(n+1)//2+1pre = a[0]cnt = 0for i in range(n):if pre==a[i]:cnt += 1else:ans -= cnt*(cnt+1)//2pre = a[i]cnt = 1ans -= cnt*(cnt+1)//2print(ans)if __name__ == "__main__":main()