結果

問題 No.1505 Zero-Product Ranges
ユーザー AAAR SalmonAAAR Salmon
提出日時 2021-05-14 22:14:35
言語 Python3
(3.11.2 + numpy 1.24.2 + scipy 1.10.1)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 10,736 KB
実行使用メモリ 12,820 KB
最終ジャッジ日時 2023-07-25 07:05:47
合計ジャッジ時間 5,898 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,764 KB
testcase_01 AC 20 ms
8,876 KB
testcase_02 AC 21 ms
8,764 KB
testcase_03 AC 81 ms
12,784 KB
testcase_04 AC 106 ms
12,660 KB
testcase_05 AC 54 ms
10,108 KB
testcase_06 AC 54 ms
10,184 KB
testcase_07 AC 45 ms
9,744 KB
testcase_08 AC 49 ms
9,732 KB
testcase_09 AC 47 ms
9,776 KB
testcase_10 AC 49 ms
9,776 KB
testcase_11 AC 56 ms
10,172 KB
testcase_12 AC 44 ms
9,572 KB
testcase_13 AC 74 ms
11,064 KB
testcase_14 AC 67 ms
10,816 KB
testcase_15 AC 103 ms
12,136 KB
testcase_16 AC 113 ms
12,760 KB
testcase_17 AC 110 ms
12,664 KB
testcase_18 AC 109 ms
12,820 KB
testcase_19 AC 21 ms
8,772 KB
testcase_20 AC 22 ms
8,756 KB
testcase_21 AC 21 ms
8,928 KB
testcase_22 AC 110 ms
11,956 KB
testcase_23 AC 108 ms
12,036 KB
testcase_24 AC 104 ms
11,988 KB
testcase_25 AC 101 ms
12,028 KB
testcase_26 AC 104 ms
11,968 KB
testcase_27 AC 102 ms
11,960 KB
testcase_28 AC 103 ms
11,980 KB
testcase_29 AC 107 ms
12,676 KB
testcase_30 AC 110 ms
11,972 KB
testcase_31 AC 105 ms
12,140 KB
testcase_32 AC 66 ms
10,920 KB
testcase_33 AC 63 ms
10,492 KB
testcase_34 AC 71 ms
10,704 KB
testcase_35 AC 57 ms
9,984 KB
testcase_36 AC 59 ms
10,104 KB
testcase_37 AC 68 ms
10,728 KB
testcase_38 AC 62 ms
10,312 KB
testcase_39 AC 63 ms
10,352 KB
testcase_40 AC 66 ms
10,696 KB
testcase_41 AC 71 ms
10,648 KB
testcase_42 AC 26 ms
8,892 KB
testcase_43 AC 29 ms
9,136 KB
testcase_44 AC 28 ms
9,196 KB
testcase_45 AC 29 ms
8,984 KB
testcase_46 AC 25 ms
8,900 KB
testcase_47 AC 30 ms
9,340 KB
testcase_48 AC 26 ms
8,940 KB
testcase_49 AC 23 ms
9,000 KB
testcase_50 AC 27 ms
9,060 KB
testcase_51 AC 28 ms
9,256 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