結果
| 問題 |
No.2956 Substitute with Average
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-11-12 03:23:19 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 397 bytes |
| コンパイル時間 | 1,020 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 33,800 KB |
| 最終ジャッジ日時 | 2024-11-12 03:24:25 |
| 合計ジャッジ時間 | 64,299 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 3 TLE * 18 |
ソースコード
import sys
input = sys.stdin.readline
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
ANS=0
for x in range(1,31):
B=[A[i]-x for i in range(N)]
S=[0]
for b in B:
S.append(S[-1]+b)
C=Counter()
C[0]=1
for i in range(N):
if A[i]==x:
s=S[i+1]
ANS+=C[s]-1
C[S[i+1]]+=1
print(1+N*(N-1)//2-ANS)
titia