結果

問題 No.1765 While Shining
ユーザー titiatitia
提出日時 2021-11-26 22:31:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 263 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 10,564 KB
実行使用メモリ 17,736 KB
最終ジャッジ日時 2023-09-12 05:10:55
合計ジャッジ時間 3,707 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,776 KB
testcase_01 AC 16 ms
7,784 KB
testcase_02 AC 16 ms
7,788 KB
testcase_03 AC 16 ms
7,784 KB
testcase_04 AC 16 ms
7,784 KB
testcase_05 AC 17 ms
7,804 KB
testcase_06 AC 17 ms
7,852 KB
testcase_07 AC 17 ms
7,804 KB
testcase_08 AC 16 ms
7,800 KB
testcase_09 AC 99 ms
10,136 KB
testcase_10 AC 131 ms
11,392 KB
testcase_11 AC 117 ms
10,708 KB
testcase_12 AC 127 ms
11,032 KB
testcase_13 AC 114 ms
10,840 KB
testcase_14 AC 142 ms
11,432 KB
testcase_15 AC 138 ms
11,368 KB
testcase_16 AC 140 ms
11,400 KB
testcase_17 AC 136 ms
11,372 KB
testcase_18 AC 143 ms
11,384 KB
testcase_19 AC 137 ms
11,468 KB
testcase_20 AC 142 ms
11,328 KB
testcase_21 AC 143 ms
11,516 KB
testcase_22 AC 140 ms
11,416 KB
testcase_23 AC 140 ms
11,444 KB
testcase_24 AC 157 ms
17,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

S=[0]*N
for i in range(N-2,-1,-1):
    if A[i]==A[i+1]:
        S[i]=1
    else:
        S[i]=S[i+1]+1

ANS=0
for i in range(N):
    if A[i]==1:
        ANS+=S[i]

print(ANS)
0