結果
| 問題 |
No.1505 Zero-Product Ranges
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-02 20:51:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 137 ms / 2,000 ms |
| コード長 | 305 bytes |
| コンパイル時間 | 205 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 113,664 KB |
| 最終ジャッジ日時 | 2024-12-25 18:53:13 |
| 合計ジャッジ時間 | 9,609 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
ans = N*(N+1)//2
for g,r in groupby(A):
if g==1:
n = len(list(r))
ans -= n*(n+1)//2
print(ans)