結果

問題 No.1505 Zero-Product Ranges
ユーザー AAAR SalmonAAAR Salmon
提出日時 2021-05-14 22:14:35
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 60 ms
使用メモリ 12,256 KB
最終ジャッジ日時 2022-11-25 18:49:28
合計ジャッジ時間 5,274 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 20 ms
8,216 KB
testcase_01 AC 20 ms
8,276 KB
testcase_02 AC 20 ms
8,256 KB
testcase_03 AC 74 ms
12,000 KB
testcase_04 AC 95 ms
12,188 KB
testcase_05 AC 52 ms
9,668 KB
testcase_06 AC 50 ms
9,464 KB
testcase_07 AC 42 ms
9,348 KB
testcase_08 AC 46 ms
9,484 KB
testcase_09 AC 44 ms
9,272 KB
testcase_10 AC 44 ms
9,460 KB
testcase_11 AC 50 ms
9,512 KB
testcase_12 AC 40 ms
9,308 KB
testcase_13 AC 65 ms
10,512 KB
testcase_14 AC 60 ms
10,356 KB
testcase_15 AC 90 ms
11,588 KB
testcase_16 AC 101 ms
12,028 KB
testcase_17 AC 101 ms
12,120 KB
testcase_18 AC 98 ms
12,080 KB
testcase_19 AC 20 ms
8,272 KB
testcase_20 AC 19 ms
8,220 KB
testcase_21 AC 19 ms
8,180 KB
testcase_22 AC 98 ms
11,608 KB
testcase_23 AC 97 ms
11,544 KB
testcase_24 AC 94 ms
11,608 KB
testcase_25 AC 91 ms
11,384 KB
testcase_26 AC 93 ms
11,560 KB
testcase_27 AC 91 ms
12,256 KB
testcase_28 AC 93 ms
11,436 KB
testcase_29 AC 99 ms
12,148 KB
testcase_30 AC 101 ms
12,068 KB
testcase_31 AC 99 ms
11,444 KB
testcase_32 AC 62 ms
10,152 KB
testcase_33 AC 59 ms
9,740 KB
testcase_34 AC 64 ms
10,372 KB
testcase_35 AC 51 ms
9,580 KB
testcase_36 AC 55 ms
9,848 KB
testcase_37 AC 60 ms
10,136 KB
testcase_38 AC 58 ms
9,916 KB
testcase_39 AC 58 ms
9,752 KB
testcase_40 AC 61 ms
10,076 KB
testcase_41 AC 65 ms
10,356 KB
testcase_42 AC 25 ms
8,536 KB
testcase_43 AC 27 ms
8,632 KB
testcase_44 AC 25 ms
8,484 KB
testcase_45 AC 26 ms
8,568 KB
testcase_46 AC 24 ms
8,512 KB
testcase_47 AC 28 ms
8,528 KB
testcase_48 AC 24 ms
8,544 KB
testcase_49 AC 22 ms
8,468 KB
testcase_50 AC 26 ms
8,580 KB
testcase_51 AC 27 ms
8,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
from math import sin, cos, tan
from functools import reduce
from collections import deque
import heapq
sys.setrecursionlimit(1000000)
intm1 = lambda x:int(x)-1

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

ans = 0
pre0 = -1
for i in range(N):
	if A[i] == 0:
		ans += i + 1
		pre0 = i
	else:
		if pre0 != -1:
			ans += pre0 + 1
print(ans)
0