結果

問題 No.1765 While Shining
ユーザー gr1msl3ygr1msl3y
提出日時 2021-11-26 22:46:44
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 261 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 106,596 KB
最終ジャッジ日時 2023-09-12 05:19:25
合計ジャッジ時間 4,129 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,600 KB
testcase_01 AC 73 ms
71,348 KB
testcase_02 AC 76 ms
71,236 KB
testcase_03 AC 71 ms
71,204 KB
testcase_04 AC 73 ms
71,412 KB
testcase_05 AC 73 ms
71,352 KB
testcase_06 AC 72 ms
71,068 KB
testcase_07 AC 73 ms
71,256 KB
testcase_08 AC 72 ms
71,316 KB
testcase_09 AC 106 ms
94,332 KB
testcase_10 AC 124 ms
106,124 KB
testcase_11 AC 114 ms
99,520 KB
testcase_12 AC 116 ms
102,724 KB
testcase_13 AC 113 ms
99,428 KB
testcase_14 AC 124 ms
106,372 KB
testcase_15 AC 123 ms
106,436 KB
testcase_16 AC 122 ms
106,596 KB
testcase_17 AC 121 ms
106,008 KB
testcase_18 AC 120 ms
106,160 KB
testcase_19 AC 123 ms
106,452 KB
testcase_20 AC 123 ms
106,216 KB
testcase_21 AC 122 ms
106,052 KB
testcase_22 AC 123 ms
106,008 KB
testcase_23 AC 121 ms
106,148 KB
testcase_24 AC 113 ms
106,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ans = 0
ct = 0
B = [0]*N
r = 0
for i in range(N):
    while r < N and (i == r or A[r-1] != A[r]):
        r += 1
    B[i] = r

for i in range(N-1):
    if A[i]:
        ans += B[i]-i-(B[i] == N)

print(ans)
0