結果
| 問題 |
No.1765 While Shining
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-30 18:27:57 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 223 ms / 2,000 ms |
| コード長 | 500 bytes |
| コンパイル時間 | 169 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 20,380 KB |
| 最終ジャッジ日時 | 2024-06-11 08:22:52 |
| 合計ジャッジ時間 | 4,758 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
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)