結果
| 問題 | No.1765 While Shining | 
| コンテスト | |
| ユーザー |  SidewaysOwl | 
| 提出日時 | 2021-11-26 22:50:24 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 81 ms / 2,000 ms | 
| コード長 | 367 bytes | 
| コンパイル時間 | 145 ms | 
| コンパイル使用メモリ | 82,528 KB | 
| 実行使用メモリ | 100,376 KB | 
| 最終ジャッジ日時 | 2024-06-29 18:20:01 | 
| 合計ジャッジ時間 | 2,594 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 22 | 
ソースコード
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)
            
            
            
        