結果

問題 No.1765 While Shining
ユーザー ああいいああいい
提出日時 2021-12-03 17:57:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 10,632 KB
実行使用メモリ 14,616 KB
最終ジャッジ日時 2023-09-19 09:38:32
合計ジャッジ時間 4,907 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,844 KB
testcase_01 AC 16 ms
7,784 KB
testcase_02 AC 16 ms
7,864 KB
testcase_03 AC 17 ms
7,796 KB
testcase_04 AC 16 ms
7,784 KB
testcase_05 AC 17 ms
7,708 KB
testcase_06 AC 17 ms
7,860 KB
testcase_07 AC 17 ms
7,780 KB
testcase_08 AC 17 ms
7,840 KB
testcase_09 AC 139 ms
10,624 KB
testcase_10 AC 198 ms
11,292 KB
testcase_11 AC 178 ms
10,812 KB
testcase_12 AC 188 ms
11,092 KB
testcase_13 AC 172 ms
11,276 KB
testcase_14 AC 211 ms
12,076 KB
testcase_15 AC 216 ms
12,160 KB
testcase_16 AC 210 ms
12,172 KB
testcase_17 AC 214 ms
12,172 KB
testcase_18 AC 214 ms
12,160 KB
testcase_19 AC 210 ms
12,088 KB
testcase_20 AC 213 ms
12,224 KB
testcase_21 AC 214 ms
12,068 KB
testcase_22 AC 212 ms
12,068 KB
testcase_23 AC 209 ms
12,128 KB
testcase_24 AC 153 ms
14,616 KB
権限があれば一括ダウンロードができます

ソースコード

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