結果

問題 No.1765 While Shining
ユーザー 👑 KazunKazun
提出日時 2021-11-26 22:30:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 455 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 107,744 KB
最終ジャッジ日時 2023-09-12 05:10:41
合計ジャッジ時間 4,004 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,300 KB
testcase_01 AC 75 ms
71,424 KB
testcase_02 AC 74 ms
71,424 KB
testcase_03 AC 74 ms
71,260 KB
testcase_04 AC 73 ms
71,368 KB
testcase_05 AC 75 ms
71,560 KB
testcase_06 AC 74 ms
71,256 KB
testcase_07 AC 72 ms
71,424 KB
testcase_08 AC 72 ms
71,532 KB
testcase_09 AC 103 ms
95,060 KB
testcase_10 AC 117 ms
107,268 KB
testcase_11 AC 110 ms
100,800 KB
testcase_12 AC 113 ms
103,912 KB
testcase_13 AC 112 ms
100,624 KB
testcase_14 AC 120 ms
107,612 KB
testcase_15 AC 118 ms
107,616 KB
testcase_16 AC 120 ms
107,744 KB
testcase_17 AC 118 ms
107,668 KB
testcase_18 AC 118 ms
107,672 KB
testcase_19 AC 119 ms
107,396 KB
testcase_20 AC 118 ms
107,608 KB
testcase_21 AC 118 ms
107,728 KB
testcase_22 AC 119 ms
107,612 KB
testcase_23 AC 118 ms
107,708 KB
testcase_24 AC 117 ms
107,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=[-1]+list(map(int,input().split()))

T=[0]*(N+1)

for x in range(N,0,-1):
    if x==N:
        T[N]=N
        continue
    elif x==N-1:
        if A[N-1]==1:
            T[N-1]=N
        else:
            T[N-1]=N-1
        continue
    if A[x]==0:
        T[x]=x
    else:
        if A[x+1]==1:
            T[x]=x+1
        else:
            T[x]=T[x+2]

X=0
for x in range(1,N+1):
    X+=T[x]-x

print(X)
0