結果

問題 No.1765 While Shining
ユーザー ああいい
提出日時 2021-12-03 17:57:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 241 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,176 KB
最終ジャッジ日時 2024-07-05 21:22:03
合計ジャッジ時間 4,930 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

S = [0] * N
now = 0
end = 0
while now < N - 1:
    if A[now] == 0:
        S[now] = 0
        now += 1
        continue
    for i in range(now,N-1):
        if A[i+1] == A[i] or i == N-2:
            end = i+1
            break
    for i in range(now,end,2):
        S[i] = end - i
    now = end
sum = 0
for i in range(N):
    sum += S[i]
print(sum)
    
#多分ok
0