結果

問題 No.989 N×Mマス計算(K以上)
ユーザー simansiman
提出日時 2020-02-14 21:34:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 317 ms / 2,000 ms
コード長 331 bytes
コンパイル時間 48 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 22,144 KB
最終ジャッジ日時 2024-04-16 01:35:24
合計ジャッジ時間 3,745 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,288 KB
testcase_01 AC 85 ms
12,160 KB
testcase_02 AC 85 ms
12,160 KB
testcase_03 AC 86 ms
12,160 KB
testcase_04 AC 86 ms
12,160 KB
testcase_05 AC 85 ms
12,160 KB
testcase_06 AC 85 ms
12,160 KB
testcase_07 AC 84 ms
12,160 KB
testcase_08 AC 89 ms
12,160 KB
testcase_09 AC 86 ms
12,032 KB
testcase_10 AC 234 ms
18,048 KB
testcase_11 AC 180 ms
18,816 KB
testcase_12 AC 242 ms
18,688 KB
testcase_13 AC 138 ms
17,408 KB
testcase_14 AC 317 ms
22,144 KB
testcase_15 AC 153 ms
13,824 KB
testcase_16 AC 215 ms
15,616 KB
testcase_17 AC 132 ms
17,152 KB
testcase_18 AC 196 ms
12,928 KB
testcase_19 AC 182 ms
19,840 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