結果

問題 No.1765 While Shining
ユーザー H3PO4H3PO4
提出日時 2021-11-26 22:37:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 10,712 KB
実行使用メモリ 12,576 KB
最終ジャッジ日時 2023-09-12 05:15:20
合計ジャッジ時間 3,559 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,808 KB
testcase_01 AC 16 ms
7,800 KB
testcase_02 AC 15 ms
7,788 KB
testcase_03 AC 15 ms
7,784 KB
testcase_04 AC 16 ms
7,800 KB
testcase_05 AC 16 ms
7,804 KB
testcase_06 AC 16 ms
7,776 KB
testcase_07 AC 16 ms
7,936 KB
testcase_08 AC 16 ms
7,828 KB
testcase_09 AC 90 ms
10,680 KB
testcase_10 AC 128 ms
11,536 KB
testcase_11 AC 112 ms
11,068 KB
testcase_12 AC 122 ms
11,016 KB
testcase_13 AC 113 ms
11,552 KB
testcase_14 AC 137 ms
12,492 KB
testcase_15 AC 138 ms
12,460 KB
testcase_16 AC 134 ms
12,568 KB
testcase_17 AC 141 ms
12,524 KB
testcase_18 AC 134 ms
12,532 KB
testcase_19 AC 134 ms
12,432 KB
testcase_20 AC 134 ms
12,480 KB
testcase_21 AC 133 ms
12,460 KB
testcase_22 AC 135 ms
12,456 KB
testcase_23 AC 136 ms
12,548 KB
testcase_24 AC 137 ms
12,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = tuple(map(int, input().split()))

ans = 0
for start in (0, 1):
    tmp = 0
    for i in range(start, N, 2):
        if A[i] == 1:
            tmp += 1
            ans += tmp
        else:
            tmp = 0
        if i + 1 < N:
            if A[i + 1] == 0:
                ans += tmp
            else:
                tmp = 0
    ans -= tmp
print(ans)
0