結果

問題 No.989 N×Mマス計算(K以上)
ユーザー simansiman
提出日時 2020-02-14 21:34:27
言語 Ruby
(3.2.2)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 331 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 11,500 KB
実行使用メモリ 23,812 KB
最終ジャッジ日時 2023-07-28 17:29:08
合計ジャッジ時間 4,567 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,240 KB
testcase_01 AC 82 ms
15,144 KB
testcase_02 AC 83 ms
15,276 KB
testcase_03 AC 81 ms
15,280 KB
testcase_04 AC 83 ms
15,132 KB
testcase_05 AC 82 ms
15,148 KB
testcase_06 AC 82 ms
15,124 KB
testcase_07 AC 80 ms
15,272 KB
testcase_08 AC 82 ms
15,032 KB
testcase_09 AC 81 ms
15,304 KB
testcase_10 AC 216 ms
20,292 KB
testcase_11 AC 170 ms
21,240 KB
testcase_12 AC 226 ms
21,028 KB
testcase_13 AC 125 ms
20,208 KB
testcase_14 AC 284 ms
23,812 KB
testcase_15 AC 140 ms
17,308 KB
testcase_16 AC 193 ms
19,328 KB
testcase_17 AC 123 ms
19,820 KB
testcase_18 AC 183 ms
16,068 KB
testcase_19 AC 173 ms
22,308 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M, K = gets.split.map(&:to_i)
op, *B = gets.chomp.split
B.map!(&:to_i).sort!
A = N.times.map { gets.to_i }
S = A.sum
ans = 0

A.each do |a|
  idx = if op == '+'
          B.bsearch_index { |b| a + b >= K }
        else
          B.bsearch_index { |b| a * b >= K }
        end

  next if idx.nil?

  ans += M - idx
end

puts ans
0