結果

問題 No.1765 While Shining
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-11-26 22:50:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 104,872 KB
最終ジャッジ日時 2023-09-12 05:20:20
合計ジャッジ時間 3,986 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,380 KB
testcase_01 AC 73 ms
71,416 KB
testcase_02 AC 76 ms
71,584 KB
testcase_03 AC 73 ms
71,264 KB
testcase_04 AC 72 ms
71,500 KB
testcase_05 AC 74 ms
71,432 KB
testcase_06 AC 71 ms
71,448 KB
testcase_07 AC 71 ms
71,428 KB
testcase_08 AC 73 ms
71,632 KB
testcase_09 AC 99 ms
93,300 KB
testcase_10 AC 115 ms
104,332 KB
testcase_11 AC 107 ms
98,416 KB
testcase_12 AC 110 ms
101,256 KB
testcase_13 AC 106 ms
98,560 KB
testcase_14 AC 112 ms
104,760 KB
testcase_15 AC 112 ms
104,412 KB
testcase_16 AC 112 ms
104,716 KB
testcase_17 AC 111 ms
104,724 KB
testcase_18 AC 112 ms
104,736 KB
testcase_19 AC 111 ms
104,744 KB
testcase_20 AC 110 ms
104,872 KB
testcase_21 AC 112 ms
104,808 KB
testcase_22 AC 111 ms
104,532 KB
testcase_23 AC 112 ms
104,724 KB
testcase_24 AC 108 ms
104,520 KB
権限があれば一括ダウンロードができます

ソースコード

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:
        if i == n-2:
            ans += 1 + cnt//2
        else:
            cnt +=2
            ans += cnt
        i += 2
    else:
        if a[i] == 1:
            ans += 1 + cnt//2
        cnt = 0
        i += 1
#     print(ans)
print(ans)
0