結果

問題 No.1765 While Shining
ユーザー horitaka1999horitaka1999
提出日時 2021-11-26 23:07:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 106,676 KB
最終ジャッジ日時 2023-09-12 05:31:21
合計ジャッジ時間 4,180 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,512 KB
testcase_01 AC 70 ms
71,460 KB
testcase_02 AC 71 ms
71,280 KB
testcase_03 AC 72 ms
71,204 KB
testcase_04 AC 71 ms
71,532 KB
testcase_05 AC 72 ms
71,496 KB
testcase_06 AC 72 ms
71,468 KB
testcase_07 AC 71 ms
71,456 KB
testcase_08 AC 73 ms
71,328 KB
testcase_09 AC 105 ms
94,004 KB
testcase_10 AC 119 ms
106,056 KB
testcase_11 AC 114 ms
99,608 KB
testcase_12 AC 117 ms
102,956 KB
testcase_13 AC 109 ms
99,368 KB
testcase_14 AC 121 ms
106,508 KB
testcase_15 AC 121 ms
106,512 KB
testcase_16 AC 123 ms
106,676 KB
testcase_17 AC 120 ms
106,468 KB
testcase_18 AC 119 ms
106,572 KB
testcase_19 AC 122 ms
106,368 KB
testcase_20 AC 122 ms
106,552 KB
testcase_21 AC 120 ms
106,548 KB
testcase_22 AC 122 ms
106,604 KB
testcase_23 AC 121 ms
106,540 KB
testcase_24 AC 115 ms
106,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
B = [0 for _ in range(N)]
cnt = 0
bef = -1
for i in reversed(range(N-1)):
    if A[i] != bef:
        bef = A[i]
        cnt += 1
        B[i] = cnt
    else:
        bef = A[i]
        cnt = 1
        B[i] = cnt
ans = 0
for i in range(N):
    if A[i] == 1 and i != N-1:
        ans += B[i]
print(ans)
0