結果

問題 No.1505 Zero-Product Ranges
ユーザー aa
提出日時 2021-05-16 20:39:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 15,332 KB
最終ジャッジ日時 2024-04-15 11:30:06
合計ジャッジ時間 6,800 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
11,648 KB
testcase_01 AC 38 ms
11,648 KB
testcase_02 AC 40 ms
11,776 KB
testcase_03 AC 117 ms
15,064 KB
testcase_04 AC 120 ms
15,216 KB
testcase_05 AC 71 ms
12,928 KB
testcase_06 AC 67 ms
12,928 KB
testcase_07 AC 61 ms
12,508 KB
testcase_08 AC 67 ms
12,800 KB
testcase_09 AC 64 ms
12,672 KB
testcase_10 AC 62 ms
12,800 KB
testcase_11 AC 68 ms
13,056 KB
testcase_12 AC 59 ms
12,484 KB
testcase_13 AC 85 ms
13,920 KB
testcase_14 AC 75 ms
13,468 KB
testcase_15 AC 109 ms
15,008 KB
testcase_16 AC 134 ms
15,212 KB
testcase_17 AC 133 ms
15,208 KB
testcase_18 AC 136 ms
15,208 KB
testcase_19 AC 39 ms
11,648 KB
testcase_20 AC 38 ms
11,776 KB
testcase_21 AC 39 ms
11,648 KB
testcase_22 AC 134 ms
15,184 KB
testcase_23 AC 135 ms
15,040 KB
testcase_24 AC 129 ms
14,988 KB
testcase_25 AC 126 ms
14,928 KB
testcase_26 AC 132 ms
14,864 KB
testcase_27 AC 127 ms
14,948 KB
testcase_28 AC 132 ms
14,968 KB
testcase_29 AC 135 ms
14,916 KB
testcase_30 AC 137 ms
15,332 KB
testcase_31 AC 130 ms
14,868 KB
testcase_32 AC 88 ms
13,592 KB
testcase_33 AC 85 ms
13,148 KB
testcase_34 AC 95 ms
13,552 KB
testcase_35 AC 81 ms
13,056 KB
testcase_36 AC 80 ms
13,056 KB
testcase_37 AC 88 ms
13,460 KB
testcase_38 AC 84 ms
13,252 KB
testcase_39 AC 85 ms
13,276 KB
testcase_40 AC 87 ms
13,464 KB
testcase_41 AC 95 ms
13,716 KB
testcase_42 AC 44 ms
11,776 KB
testcase_43 AC 48 ms
12,032 KB
testcase_44 AC 46 ms
11,904 KB
testcase_45 AC 50 ms
11,904 KB
testcase_46 AC 45 ms
11,776 KB
testcase_47 AC 55 ms
12,032 KB
testcase_48 AC 45 ms
11,776 KB
testcase_49 AC 40 ms
11,648 KB
testcase_50 AC 45 ms
11,904 KB
testcase_51 AC 47 ms
12,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import sys
from collections import deque,defaultdict,Counter
from functools import lru_cache,reduce
from math import gcd as Gcd
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines

N,*A=map(int,read().split())
ans=N*(N+1)//2
cur=0
while cur!=N:
    if A[cur]==0:
        cur+=1
        continue
    i=cur+1
    while i!=N and A[i]==1:
        i+=1
    ans-=(i-cur)*(i-cur+1)//2
    cur=i
print(ans)
0