結果

問題 No.1765 While Shining
ユーザー kyskys
提出日時 2021-11-26 23:01:56
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 998 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 117,436 KB
最終ジャッジ日時 2023-09-12 05:26:45
合計ジャッジ時間 5,023 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,348 KB
testcase_01 AC 80 ms
71,304 KB
testcase_02 AC 79 ms
71,028 KB
testcase_03 AC 79 ms
71,228 KB
testcase_04 AC 79 ms
71,012 KB
testcase_05 AC 78 ms
71,212 KB
testcase_06 AC 77 ms
71,252 KB
testcase_07 RE -
testcase_08 AC 78 ms
71,196 KB
testcase_09 RE -
testcase_10 AC 121 ms
104,480 KB
testcase_11 AC 115 ms
98,308 KB
testcase_12 AC 117 ms
101,008 KB
testcase_13 RE -
testcase_14 AC 122 ms
104,372 KB
testcase_15 AC 125 ms
104,312 KB
testcase_16 AC 123 ms
104,516 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 126 ms
104,400 KB
testcase_20 AC 123 ms
104,304 KB
testcase_21 RE -
testcase_22 AC 125 ms
104,824 KB
testcase_23 RE -
testcase_24 AC 120 ms
117,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
def iinput(): return int(input())
def sinput(): return input().rstrip()
def i0input(): return int(input()) - 1
def linput(): return list(input().split())
def liinput(): return list(map(int, input().split()))
def miinput(): return map(int, input().split())
def li0input(): return list(map(lambda x: int(x) - 1, input().split()))
def mi0input(): return map(lambda x: int(x) - 1, input().split())
INF = 10**20
MOD = 1000000007

N = iinput()
A = liinput()

ans = 0
tmp = []
for i, a in enumerate(A):
    if tmp == []:
        if a == 1:
            tmp.append(a)
    else:
        if a != tmp[-1]:
            tmp.append(a)
        else:
            if tmp[0] == 1:
                l = len(tmp)
                ll = l // 2
                ans += ll * (ll + 1) + (l % 2) * (ll + 1)
            if a == 0:
                tmp = []
            else:
                tmp = [a]
_ = tmp.pop()
l = len(tmp)
ll = l // 2
ans += ll * (ll + 1) + (l % 2) * (ll + 1)
print(ans)
0