結果

問題 No.11 カードマッチ
ユーザー simansiman
提出日時 2016-03-27 03:19:49
言語 Ruby
(3.4.1)
結果
AC  
実行時間 180 ms / 5,000 ms
コード長 556 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 20,096 KB
最終ジャッジ日時 2024-10-11 20:03:02
合計ジャッジ時間 3,109 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  def initialize
    w = gets.to_i
    h = gets.to_i
    n = gets.to_i

    marks = Array.new(w, false)
    nums = Hash.new(false)
    sum = 0

    n.times do
      s, k = gets.chomp.split.map{|i| i.to_i-1}

      if !marks[s]
        marks[s] = true
      end

      if !nums[k]
        nums[k] = true
        sum += 1
      end
    end

    answer = 0

    marks.each do |mark|
      num = 0

      if mark
        num += h
      else
        num += sum
      end

      answer += num
    end

    puts answer - n
  end
end

Yukicoder.new
0