結果

問題 No.1765 While Shining
ユーザー tktk_snsntktk_snsn
提出日時 2021-11-26 22:40:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 175 ms / 2,000 ms
コード長 240 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 10,420 KB
実行使用メモリ 17,992 KB
最終ジャッジ日時 2023-09-12 05:16:10
合計ジャッジ時間 3,908 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,932 KB
testcase_01 AC 15 ms
7,884 KB
testcase_02 AC 16 ms
7,780 KB
testcase_03 AC 15 ms
7,880 KB
testcase_04 AC 15 ms
7,956 KB
testcase_05 AC 16 ms
7,796 KB
testcase_06 AC 15 ms
7,704 KB
testcase_07 AC 15 ms
7,884 KB
testcase_08 AC 16 ms
7,768 KB
testcase_09 AC 103 ms
10,296 KB
testcase_10 AC 144 ms
11,400 KB
testcase_11 AC 127 ms
10,860 KB
testcase_12 AC 139 ms
10,948 KB
testcase_13 AC 124 ms
11,288 KB
testcase_14 AC 146 ms
12,088 KB
testcase_15 AC 154 ms
12,024 KB
testcase_16 AC 146 ms
11,916 KB
testcase_17 AC 146 ms
11,988 KB
testcase_18 AC 143 ms
11,960 KB
testcase_19 AC 145 ms
12,176 KB
testcase_20 AC 146 ms
12,084 KB
testcase_21 AC 148 ms
11,960 KB
testcase_22 AC 147 ms
12,044 KB
testcase_23 AC 146 ms
12,064 KB
testcase_24 AC 175 ms
17,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

cnt = [0] * N
cnt[N-1] = -1
for i in reversed(range(N-1)):
    if A[i] != A[i+1]:
        cnt[i] = cnt[i + 1] + 1

ans = 0
for i in range(N-1):
    ans += A[i] * (cnt[i] + 1)
print(ans)
0