結果

問題 No.1765 While Shining
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-11-26 22:30:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 1,208 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 110,224 KB
最終ジャッジ日時 2023-09-12 05:10:31
合計ジャッジ時間 5,148 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,272 KB
testcase_01 AC 72 ms
71,344 KB
testcase_02 AC 71 ms
71,224 KB
testcase_03 AC 69 ms
71,568 KB
testcase_04 AC 70 ms
71,332 KB
testcase_05 AC 74 ms
76,056 KB
testcase_06 AC 71 ms
71,284 KB
testcase_07 AC 71 ms
71,256 KB
testcase_08 AC 77 ms
76,296 KB
testcase_09 AC 123 ms
101,108 KB
testcase_10 AC 134 ms
110,224 KB
testcase_11 AC 126 ms
104,648 KB
testcase_12 AC 129 ms
107,492 KB
testcase_13 AC 129 ms
105,176 KB
testcase_14 AC 150 ms
109,868 KB
testcase_15 AC 148 ms
109,764 KB
testcase_16 AC 152 ms
109,768 KB
testcase_17 AC 150 ms
109,808 KB
testcase_18 AC 151 ms
109,904 KB
testcase_19 AC 151 ms
109,752 KB
testcase_20 AC 149 ms
109,592 KB
testcase_21 AC 152 ms
109,576 KB
testcase_22 AC 149 ms
109,900 KB
testcase_23 AC 149 ms
109,828 KB
testcase_24 AC 146 ms
109,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

"""

import sys
from sys import stdin

N = int(stdin.readline())

A = list(map(int,stdin.readline().split()))

dp = [[0,0] for i in range(N)]

for i in range(N-2,-1,-1):

    for turn in range(2):

        now = A[i] ^ turn
        if now == 1:
            dp[i][turn] = dp[i+1][turn^1] + 1

ans = 0
for i in range(N):
    ans += dp[i][0]
print (ans)
0