結果

問題 No.647 明太子
ユーザー gemmarogemmaro
提出日時 2020-02-14 10:41:43
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 743 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 407,660 KB
最終ジャッジ日時 2024-04-16 00:10:31
合計ジャッジ時間 16,774 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
12,288 KB
testcase_01 AC 95 ms
12,160 KB
testcase_02 AC 89 ms
12,416 KB
testcase_03 AC 88 ms
12,160 KB
testcase_04 AC 92 ms
12,160 KB
testcase_05 AC 90 ms
12,416 KB
testcase_06 AC 88 ms
12,160 KB
testcase_07 AC 89 ms
12,160 KB
testcase_08 AC 90 ms
12,288 KB
testcase_09 AC 128 ms
15,104 KB
testcase_10 AC 173 ms
17,408 KB
testcase_11 AC 107 ms
12,800 KB
testcase_12 AC 155 ms
16,384 KB
testcase_13 AC 238 ms
23,680 KB
testcase_14 AC 1,755 ms
129,196 KB
testcase_15 AC 318 ms
29,824 KB
testcase_16 AC 149 ms
15,744 KB
testcase_17 AC 2,176 ms
157,224 KB
testcase_18 AC 2,340 ms
171,520 KB
testcase_19 AC 788 ms
78,336 KB
testcase_20 AC 839 ms
83,584 KB
testcase_21 AC 360 ms
38,016 KB
testcase_22 MLE -
testcase_23 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

class Array
  def accepts
    FOODS.map.with_index do |food, index|
      index if food[0] <= self[0] && food[1] >= self[1]
    end
  end
end

MEMBERS = gets.to_i.times.map { gets.chomp.split.map(&:to_i) }
FOODS = gets.to_i.times.map { gets.chomp.split.map(&:to_i) }

FOODS_WITH_NUM = MEMBERS.map(&:accepts)
                        .flatten
                        .compact
                        .sort
                        .group_by(&:itself)
                        .map { |i, j| [i, j.size] }

MAX = (FOODS_WITH_NUM.max_by { |_, k| k } || [nil, 0])[1]
MAXS = FOODS_WITH_NUM.filter { |_, j| j == MAX }

puts(if MAXS.empty?
       0
     else
       MAXS.map { |k, _v| k + 1 }.uniq.sort.join("\n")
     end)
0