結果

問題 No.647 明太子
ユーザー gemmarogemmaro
提出日時 2020-03-05 10:07:34
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 925 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 334,336 KB
最終ジャッジ日時 2024-04-22 02:09:40
合計ジャッジ時間 14,235 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
12,288 KB
testcase_01 AC 82 ms
12,288 KB
testcase_02 AC 79 ms
12,288 KB
testcase_03 AC 79 ms
12,160 KB
testcase_04 AC 81 ms
12,160 KB
testcase_05 AC 79 ms
12,416 KB
testcase_06 AC 79 ms
12,160 KB
testcase_07 AC 90 ms
12,288 KB
testcase_08 AC 83 ms
12,160 KB
testcase_09 AC 119 ms
14,848 KB
testcase_10 AC 167 ms
17,536 KB
testcase_11 AC 103 ms
12,928 KB
testcase_12 AC 135 ms
16,384 KB
testcase_13 AC 210 ms
23,808 KB
testcase_14 AC 1,458 ms
126,464 KB
testcase_15 AC 277 ms
29,184 KB
testcase_16 AC 136 ms
15,872 KB
testcase_17 AC 1,874 ms
157,440 KB
testcase_18 AC 1,976 ms
171,520 KB
testcase_19 AC 694 ms
78,336 KB
testcase_20 AC 735 ms
83,584 KB
testcase_21 AC 314 ms
38,144 KB
testcase_22 MLE -
testcase_23 AC 89 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

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

# ----------------------------------------------------------------- input

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

# ----------------------------------------------------------------- calc

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

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

RESULT = MAXS.empty? ? 0 : MAXS.map { |k, _v| k + 1 }.uniq

# ----------------------------------------------------------------- output

puts RESULT
0