結果

問題 No.1765 While Shining
ユーザー Nishin-0141Nishin-0141
提出日時 2022-01-30 18:27:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 10,712 KB
実行使用メモリ 17,852 KB
最終ジャッジ日時 2023-09-02 01:44:57
合計ジャッジ時間 4,564 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,812 KB
testcase_01 AC 15 ms
7,860 KB
testcase_02 AC 15 ms
7,828 KB
testcase_03 AC 15 ms
7,848 KB
testcase_04 AC 16 ms
7,876 KB
testcase_05 AC 16 ms
7,824 KB
testcase_06 AC 15 ms
7,784 KB
testcase_07 AC 15 ms
7,888 KB
testcase_08 AC 17 ms
7,884 KB
testcase_09 AC 127 ms
12,288 KB
testcase_10 AC 178 ms
13,876 KB
testcase_11 AC 158 ms
13,376 KB
testcase_12 AC 169 ms
13,564 KB
testcase_13 AC 153 ms
13,260 KB
testcase_14 AC 185 ms
14,764 KB
testcase_15 AC 186 ms
14,672 KB
testcase_16 AC 185 ms
14,636 KB
testcase_17 AC 189 ms
14,680 KB
testcase_18 AC 186 ms
14,736 KB
testcase_19 AC 186 ms
14,724 KB
testcase_20 AC 186 ms
14,684 KB
testcase_21 AC 190 ms
14,680 KB
testcase_22 AC 189 ms
14,628 KB
testcase_23 AC 191 ms
14,744 KB
testcase_24 AC 192 ms
17,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))

a_reverse = a[::-1]
num = [0]*n
check = [True]*n
cnt = 0
ans = 0
for i in range(n-1):
    # cnt = 0
    if a_reverse[i] != a_reverse[i + 1]:
        cnt += 1
        check[i + 1] = check[i]
    else:
        cnt = 0
        check[i + 1] = False
    if a_reverse[i + 1]:
        num[i + 1] = cnt

for i in range(1, n):
    if a_reverse[i] and not check[i]:
        ans += 1

# print(*a_reverse)
# print(*num)
# print(*check)
print(sum(num) + ans)
0