結果

問題 No.989 N×Mマス計算(K以上)
ユーザー gemmarogemmaro
提出日時 2020-02-14 22:42:43
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 24,320 KB
最終ジャッジ日時 2024-04-16 02:43:46
合計ジャッジ時間 5,023 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
17,536 KB
testcase_01 AC 88 ms
12,416 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 94 ms
12,416 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

N, M, K = gets.chomp.split.map(&:to_i)

ROW = gets.chomp.split
OP = ROW[0].intern
BS = ROW[1..-1].map(&:to_i).reject { |b| b >= K }.sort

AS = N.times.map { gets.to_i }.reject { |a| a >= K }.sort

COUNT = N * M - AS.size * BS.size

puts(case OP
     when :+
       AS.map do |a|
         count = 0
         BS.each_with_index do |b, i|
           if a + b >= K
             count += AS.size - i + 1
             break
           end
         end
         count
       end.sum
     else
       AS.map do |a|
         count = 0
         BS.each_with_index do |b, i|
           if a * b >= K
             count += AS.size - i + 1
             break
           end
         end
         count
       end.sum
     end + COUNT)
0