結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,840 KB
testcase_01 AC 14 ms
7,804 KB
testcase_02 AC 15 ms
7,800 KB
testcase_03 AC 14 ms
7,824 KB
testcase_04 AC 15 ms
7,904 KB
testcase_05 AC 15 ms
7,968 KB
testcase_06 AC 14 ms
7,876 KB
testcase_07 AC 14 ms
7,788 KB
testcase_08 AC 15 ms
7,836 KB
testcase_09 AC 117 ms
11,008 KB
testcase_10 AC 165 ms
12,276 KB
testcase_11 AC 144 ms
12,012 KB
testcase_12 AC 156 ms
12,340 KB
testcase_13 AC 145 ms
12,212 KB
testcase_14 AC 174 ms
12,780 KB
testcase_15 AC 178 ms
12,804 KB
testcase_16 AC 175 ms
12,840 KB
testcase_17 AC 179 ms
12,732 KB
testcase_18 AC 179 ms
12,740 KB
testcase_19 AC 182 ms
12,740 KB
testcase_20 AC 175 ms
12,744 KB
testcase_21 AC 177 ms
12,796 KB
testcase_22 AC 177 ms
12,736 KB
testcase_23 AC 180 ms
12,740 KB
testcase_24 AC 177 ms
12,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

a_reverse = a[::-1]
check = [True]*n
cnt = 0
ans = 0
for i in range(n-1):
    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]:
        ans += cnt

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

print(ans)
0