結果

問題 No.1505 Zero-Product Ranges
ユーザー gemmarogemmaro
提出日時 2021-05-26 23:10:51
言語 Ruby
(3.3.0)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 42 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 36,036 KB
最終ジャッジ日時 2024-04-23 16:32:45
合計ジャッジ時間 11,856 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
12,288 KB
testcase_01 AC 87 ms
12,032 KB
testcase_02 AC 85 ms
12,288 KB
testcase_03 AC 207 ms
31,360 KB
testcase_04 AC 287 ms
36,036 KB
testcase_05 AC 144 ms
20,352 KB
testcase_06 AC 137 ms
18,816 KB
testcase_07 AC 122 ms
17,408 KB
testcase_08 AC 127 ms
18,688 KB
testcase_09 AC 129 ms
17,536 KB
testcase_10 AC 156 ms
21,248 KB
testcase_11 AC 167 ms
23,296 KB
testcase_12 AC 144 ms
16,880 KB
testcase_13 AC 197 ms
28,544 KB
testcase_14 AC 186 ms
26,112 KB
testcase_15 AC 275 ms
35,584 KB
testcase_16 AC 258 ms
32,700 KB
testcase_17 AC 257 ms
32,704 KB
testcase_18 AC 248 ms
32,576 KB
testcase_19 AC 87 ms
12,288 KB
testcase_20 AC 90 ms
12,160 KB
testcase_21 AC 89 ms
12,032 KB
testcase_22 AC 255 ms
32,564 KB
testcase_23 AC 242 ms
32,404 KB
testcase_24 AC 249 ms
32,896 KB
testcase_25 AC 240 ms
32,000 KB
testcase_26 AC 248 ms
32,896 KB
testcase_27 AC 243 ms
32,640 KB
testcase_28 AC 247 ms
32,640 KB
testcase_29 AC 255 ms
32,484 KB
testcase_30 AC 252 ms
32,672 KB
testcase_31 AC 240 ms
32,896 KB
testcase_32 AC 171 ms
23,424 KB
testcase_33 AC 167 ms
22,912 KB
testcase_34 AC 179 ms
24,064 KB
testcase_35 AC 148 ms
21,632 KB
testcase_36 AC 150 ms
22,016 KB
testcase_37 AC 167 ms
23,296 KB
testcase_38 AC 167 ms
22,784 KB
testcase_39 AC 167 ms
23,040 KB
testcase_40 AC 175 ms
23,296 KB
testcase_41 AC 182 ms
24,832 KB
testcase_42 AC 96 ms
12,800 KB
testcase_43 AC 102 ms
13,312 KB
testcase_44 AC 101 ms
13,568 KB
testcase_45 AC 102 ms
13,440 KB
testcase_46 AC 98 ms
12,672 KB
testcase_47 AC 106 ms
14,208 KB
testcase_48 AC 97 ms
12,672 KB
testcase_49 AC 96 ms
12,672 KB
testcase_50 AC 101 ms
13,440 KB
testcase_51 AC 99 ms
13,568 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def solve
  A.map
   .with_index
   .select { |a, _| a.zero? }
   .map { |_, i| i }
   .tap { _1.unshift(-1) }
   .each_cons(2)
   .map { |prev, now| (now - prev) * (N - now) }
   .sum
end

N = gets.to_i
A = gets.split.map { _1.to_i }

puts solve
0