結果

問題 No.989 N×Mマス計算(K以上)
ユーザー gemmarogemmaro
提出日時 2020-02-14 21:56:31
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 675 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 75,392 KB
最終ジャッジ日時 2024-04-16 01:56:50
合計ジャッジ時間 4,925 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
17,664 KB
testcase_01 AC 89 ms
12,160 KB
testcase_02 AC 87 ms
12,160 KB
testcase_03 AC 88 ms
12,288 KB
testcase_04 AC 89 ms
12,416 KB
testcase_05 AC 91 ms
12,160 KB
testcase_06 AC 87 ms
12,288 KB
testcase_07 AC 88 ms
12,160 KB
testcase_08 AC 90 ms
12,032 KB
testcase_09 AC 89 ms
12,288 KB
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)

AS = N.times.map do
  gets.to_i
end

count_a = AS.filter { |a| a >= K }.size
count_b = BS.filter { |b| b >= K }.size
COUNT = count_a * M + count_b * N - count_a * count_b

A_REMAIN = AS.reject { |a| a >= K }
B_REMAIN = BS.reject { |b| b >= K }

puts(case OP
     when :+
       A_REMAIN.map do |a|
         B_REMAIN.map { |b| a + b }
         .filter { |c| c >= K }.size
       end .sum
     when :*
       A_REMAIN.map do |a|
         B_REMAIN.map { |b| a * b }
         .filter { |c| c >= K }.size
       end .sum
     end + COUNT)
0