結果

問題 No.1765 While Shining
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-11-26 22:41:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 294 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 87,352 KB
実行使用メモリ 104,828 KB
最終ジャッジ日時 2023-09-12 05:17:09
合計ジャッジ時間 4,132 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,464 KB
testcase_01 AC 75 ms
71,320 KB
testcase_02 AC 73 ms
71,388 KB
testcase_03 AC 74 ms
71,408 KB
testcase_04 WA -
testcase_05 AC 75 ms
71,244 KB
testcase_06 AC 73 ms
71,388 KB
testcase_07 AC 72 ms
71,504 KB
testcase_08 AC 75 ms
71,412 KB
testcase_09 AC 102 ms
93,104 KB
testcase_10 AC 115 ms
104,588 KB
testcase_11 AC 106 ms
98,076 KB
testcase_12 AC 111 ms
101,312 KB
testcase_13 AC 108 ms
98,340 KB
testcase_14 AC 114 ms
104,488 KB
testcase_15 AC 115 ms
104,528 KB
testcase_16 AC 115 ms
104,600 KB
testcase_17 AC 115 ms
104,828 KB
testcase_18 AC 114 ms
104,780 KB
testcase_19 AC 114 ms
104,524 KB
testcase_20 AC 117 ms
104,664 KB
testcase_21 AC 114 ms
104,516 KB
testcase_22 WA -
testcase_23 AC 115 ms
104,724 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
ans = 0
i = 0
cnt = 0
while i <= n-2:
    if a[i] == 1 and a[i+1] == 0:
        cnt +=2
        ans += cnt
        i += 2
    else:
        if a[i] == 1:
            ans += 1 + cnt//2
        cnt = 0
        i += 1
#     print(ans)
print(ans)
0