結果
| 問題 |
No.1765 While Shining
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-27 17:45:08 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 178 ms / 2,000 ms |
| コード長 | 610 bytes |
| コンパイル時間 | 619 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 14,048 KB |
| 最終ジャッジ日時 | 2024-06-30 08:36:24 |
| 合計ジャッジ時間 | 4,702 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
N = int(input())
A = list(map(int,input().split()))
L = 0
cand = []
flg = 0
for i in range(N):
if A[i] == 1 and L == 0:
st = i
L += 1
flg = 1
elif A[i] == 0:
if flg == 1:
flg = 0
L += 1
else:
cand.append(L)
L = 0
elif A[i] == 1 and flg == 0:
L += 1
flg = 1
else:
st = i
cand.append(L)
L = 1
flg = 1
cand.append(L-1)
ans = 0
for i in cand:
if i%2 == 1:
ans += ((i+1)//2)**2
else:
m = i//2
ans += m*(m+1)
print(ans)
#print(cand)