結果

問題 No.1765 While Shining
ユーザー first_vilfirst_vil
提出日時 2021-10-21 20:41:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 299 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 19,552 KB
最終ジャッジ日時 2023-09-12 04:45:05
合計ジャッジ時間 4,209 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,760 KB
testcase_01 AC 15 ms
7,812 KB
testcase_02 AC 14 ms
7,792 KB
testcase_03 AC 15 ms
7,816 KB
testcase_04 AC 15 ms
7,780 KB
testcase_05 AC 15 ms
7,760 KB
testcase_06 AC 15 ms
7,940 KB
testcase_07 AC 15 ms
7,796 KB
testcase_08 AC 15 ms
7,744 KB
testcase_09 AC 121 ms
15,212 KB
testcase_10 AC 176 ms
18,188 KB
testcase_11 AC 155 ms
17,340 KB
testcase_12 AC 167 ms
17,780 KB
testcase_13 AC 149 ms
16,936 KB
testcase_14 AC 189 ms
19,376 KB
testcase_15 AC 182 ms
19,504 KB
testcase_16 AC 185 ms
19,380 KB
testcase_17 AC 191 ms
19,552 KB
testcase_18 AC 185 ms
19,336 KB
testcase_19 AC 189 ms
19,408 KB
testcase_20 AC 187 ms
19,432 KB
testcase_21 AC 187 ms
19,336 KB
testcase_22 AC 186 ms
19,416 KB
testcase_23 AC 186 ms
19,400 KB
testcase_24 AC 174 ms
19,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
b = a[:]
for i in range(1,n,2):
    b[i] ^= 1
b.append(-1)
pre = n
c = [0]*n
for i in range(n-1,-1,-1):
    if b[i] != b[pre]:
        pre = i
    c[i] = pre + 1

ans = 0
for i in range(n):
    if a[i]:
        ans += min(c[i], n-1) - i
print(ans)
0