結果

問題 No.1765 While Shining
ユーザー mkawa2mkawa2
提出日時 2021-11-26 22:31:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 972 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 118,512 KB
最終ジャッジ日時 2023-09-12 05:10:47
合計ジャッジ時間 4,526 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,320 KB
testcase_01 AC 77 ms
71,348 KB
testcase_02 AC 78 ms
71,116 KB
testcase_03 AC 77 ms
71,140 KB
testcase_04 AC 78 ms
71,256 KB
testcase_05 AC 84 ms
75,808 KB
testcase_06 AC 78 ms
71,236 KB
testcase_07 AC 80 ms
71,336 KB
testcase_08 AC 87 ms
75,676 KB
testcase_09 AC 125 ms
108,612 KB
testcase_10 AC 146 ms
117,432 KB
testcase_11 AC 136 ms
118,512 KB
testcase_12 AC 140 ms
112,620 KB
testcase_13 AC 134 ms
118,488 KB
testcase_14 AC 145 ms
117,812 KB
testcase_15 AC 144 ms
117,488 KB
testcase_16 AC 144 ms
117,552 KB
testcase_17 AC 143 ms
117,504 KB
testcase_18 AC 143 ms
117,708 KB
testcase_19 AC 144 ms
117,612 KB
testcase_20 AC 146 ms
117,560 KB
testcase_21 AC 148 ms
117,980 KB
testcase_22 AC 145 ms
117,536 KB
testcase_23 AC 146 ms
117,604 KB
testcase_24 AC 143 ms
117,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 18446744073709551615
# inf = 4294967295
# md = 10**9+7
md = 998244353

def solve(p):
    bb = [a if i & 1 == p else 1-a for i, a in enumerate(aa)]
    bb[-1] = 0
    for i in range(n-1)[::-1]:
        if bb[i]: bb[i] += bb[i+1]
    res = 0
    # print(p, bb)
    for i, b in enumerate(bb):
        if i & 1 == p: res += b
    return res

n = II()
aa = LI()
ans = solve(0)+solve(1)
print(ans)
0