結果
| 問題 | 
                            No.1505 Zero-Product Ranges
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-01-02 17:53:17 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 254 bytes | 
| コンパイル時間 | 470 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 259,200 KB | 
| 最終ジャッジ日時 | 2024-10-11 21:41:34 | 
| 合計ジャッジ時間 | 8,270 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | TLE * 2 -- * 47 | 
ソースコード
N = int(input())
A = input().replace(' ', '')
all = N * (N + 1) // 2
i = 0
onecnt = 0
for i in range(N + 1, 0, -1):
    o = A.count('1' * i)
    if o > 0:
        onecnt += (i * (i + 1) // 2) * o
        A = A.replace('1' * i, '')
print(all - onecnt)