結果

問題 No.2956 Substitute with Average
ユーザー rin204
提出日時 2024-11-08 21:42:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 304 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 226,292 KB
最終ジャッジ日時 2024-11-08 21:43:08
合計ジャッジ時間 9,600 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))

ans = 0

for t in range(1, 31):
    B = [a - t for a in A]
    tot = 0
    cnt = {0: 1}
    for b in B:
        if b == 0:
            ans += cnt.get(tot, 0)
        tot += b
        cnt[tot] = cnt.get(tot, 0) + 1


print(n * (n + 1) // 2 - ans + 1)
0