結果

問題 No.647 明太子
ユーザー siman
提出日時 2020-12-12 08:13:47
言語 Ruby
(3.4.1)
結果
AC  
実行時間 1,017 ms / 4,500 ms
コード長 436 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-09-19 21:45:49
合計ジャッジ時間 6,344 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
persons = N.times.map { gets.split.map(&:to_i) }

M = gets.to_i
mentaikos = M.times.map { gets.split.map(&:to_i) }

max_cnt = 1
ans = []

mentaikos.each.with_index(1) do |(x, y), idx|
  cnt = 0

  persons.each do |a, b|
    next if a < x
    next if b > y

    cnt += 1
  end

  if max_cnt < cnt
    max_cnt = cnt
    ans = [idx]
  elsif max_cnt == cnt
    ans << idx
  end
end

if ans.empty?
  puts 0
else
  puts ans
end
0