結果
問題 | No.2956 Substitute with Average |
ユーザー |
👑 |
提出日時 | 2024-11-08 22:08:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 770 ms / 3,000 ms |
コード長 | 468 bytes |
コンパイル時間 | 291 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 242,444 KB |
最終ジャッジ日時 | 2024-11-08 22:08:49 |
合計ジャッジ時間 | 13,938 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
n = int(input())A = list(map(int, input().split()))ans = n * (n + 1) // 2for t in range(1, 31):B = [a - t for a in A]cnt = {}tot = 0cnt[0] = 1for b in B:tot += bans -= cnt.get(tot, 0)cnt[tot] = cnt.get(tot, 0) + 1cnt = {}tot = 0for b in B:if b != 0:cnt[tot] = cnt.get(tot, 0) + 1tot += bif b != 0:ans += cnt.get(tot, 0)ans += 1print(ans)