結果

問題 No.2684 折々の色
ユーザー tomerun
提出日時 2024-03-20 21:46:32
言語 Crystal
(1.14.0)
結果
AC  
実行時間 587 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 13,814 ms
コンパイル使用メモリ 295,736 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2024-09-30 07:34:56
合計ジャッジ時間 31,050 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 56
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = read_line.split.map(&.to_i)
x = read_line.split.map(&.to_i)
t = [] of Int32
cards = Hash(Array(Int32), Array(Int32)).new { |h, k| h[k] = [] of Int32 }
cs = Array.new(n) do |i|
  e = read_line.split.map(&.to_i)
  t << e[-1]
  cards[e[..-2].map { |v| v * t[-1] }] << i
  e[..-2]
end
z = Array.new(m, 0)
n.times do |i|
  if t[i] == 100
    if x == cs[i]
      puts "Yes"
      exit
    end
    next
  end
  ok = true
  m.times do |j|
    z[j] = 10000 * x[j] - 100 * t[i] * cs[i][j]
    if z[j] % (100 - t[i]) != 0
      ok = false
      break
    else
      z[j] //= (100 - t[i])
    end
  end
  next if !ok
  if !cards[z].select { |v| v != i }.empty?
    puts "Yes"
    exit
  end
end
puts "No"
0