結果
問題 |
No.2956 Substitute with Average
|
ユーザー |
|
提出日時 | 2024-11-08 22:29:55 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 415 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 82,856 KB |
実行使用メモリ | 324,488 KB |
最終ジャッジ日時 | 2024-11-08 22:30:31 |
合計ジャッジ時間 | 24,755 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 14 |
ソースコード
from collections import Counter N=int(input()) A=list(map(int,input().split())) ans=N*(N+1)//2 for i in range(1,30): cum=[0]*(N+1) for j in range(N): cum[j+1]=cum[j]+(A[j]-i) left=Counter() dl=Counter() cnt2=Counter({0:1}) for j in range(N): if A[j]!=i: left[cum[j]]+=1 if A[j]!=i: dl[cum[j+1]]+=left[cum[j+1]] cnt2[cum[j+1]]+=1 for c in cnt2: ans-=(cnt2[c]*(cnt2[c]-1)//2-dl[c]) print(1+ans)