結果

問題 No.1505 Zero-Product Ranges
ユーザー maguroflymagurofly
提出日時 2022-01-27 13:13:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 397 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 11,456 KB
実行使用メモリ 28,884 KB
最終ジャッジ日時 2023-08-26 08:54:33
合計ジャッジ時間 15,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,048 KB
testcase_01 AC 76 ms
15,192 KB
testcase_02 AC 77 ms
15,180 KB
testcase_03 AC 397 ms
28,860 KB
testcase_04 AC 369 ms
28,660 KB
testcase_05 AC 189 ms
20,320 KB
testcase_06 AC 180 ms
20,064 KB
testcase_07 AC 151 ms
19,148 KB
testcase_08 AC 169 ms
19,704 KB
testcase_09 AC 166 ms
19,568 KB
testcase_10 AC 162 ms
19,400 KB
testcase_11 AC 181 ms
20,472 KB
testcase_12 AC 143 ms
18,736 KB
testcase_13 AC 237 ms
23,400 KB
testcase_14 AC 222 ms
22,296 KB
testcase_15 AC 346 ms
28,076 KB
testcase_16 AC 374 ms
28,884 KB
testcase_17 AC 364 ms
28,656 KB
testcase_18 AC 363 ms
28,708 KB
testcase_19 AC 72 ms
15,336 KB
testcase_20 AC 73 ms
15,148 KB
testcase_21 AC 72 ms
15,160 KB
testcase_22 AC 359 ms
28,676 KB
testcase_23 AC 358 ms
28,280 KB
testcase_24 AC 353 ms
28,096 KB
testcase_25 AC 338 ms
27,380 KB
testcase_26 AC 346 ms
28,112 KB
testcase_27 AC 341 ms
27,500 KB
testcase_28 AC 345 ms
27,740 KB
testcase_29 AC 355 ms
28,196 KB
testcase_30 AC 368 ms
28,740 KB
testcase_31 AC 358 ms
28,136 KB
testcase_32 AC 232 ms
22,148 KB
testcase_33 AC 215 ms
22,112 KB
testcase_34 AC 235 ms
22,612 KB
testcase_35 AC 180 ms
20,420 KB
testcase_36 AC 189 ms
20,596 KB
testcase_37 AC 223 ms
21,980 KB
testcase_38 AC 208 ms
21,832 KB
testcase_39 AC 214 ms
22,080 KB
testcase_40 AC 223 ms
22,504 KB
testcase_41 AC 247 ms
23,048 KB
testcase_42 AC 85 ms
15,476 KB
testcase_43 AC 96 ms
16,156 KB
testcase_44 AC 91 ms
16,080 KB
testcase_45 AC 94 ms
16,016 KB
testcase_46 AC 85 ms
15,296 KB
testcase_47 AC 97 ms
16,304 KB
testcase_48 AC 89 ms
15,748 KB
testcase_49 AC 78 ms
15,152 KB
testcase_50 AC 92 ms
15,824 KB
testcase_51 AC 93 ms
16,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)

zero_count = [0]
A.each do |x|
    zero_count << zero_count[-1] + (x == 0 ? 1 : 0)
end

ans = 0
N.times do |l|
    ac = l
    wa = N + 1
    while wa - ac > 1
        wj = (ac + wa) / 2
        if zero_count[wj] <= zero_count[l]
            ac = wj
        else
            wa = wj
        end
    end
    ans += N - ac
end

puts ans
0