結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー ryoo14ryoo14
提出日時 2016-11-28 23:25:36
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,972 ms / 2,000 ms
コード長 1,487 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 21,076 KB
最終ジャッジ日時 2023-08-18 08:58:05
合計ジャッジ時間 16,705 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,144 KB
testcase_01 AC 80 ms
15,240 KB
testcase_02 AC 86 ms
15,036 KB
testcase_03 AC 99 ms
15,464 KB
testcase_04 AC 97 ms
15,580 KB
testcase_05 AC 1,517 ms
17,892 KB
testcase_06 AC 1,188 ms
19,836 KB
testcase_07 AC 223 ms
16,544 KB
testcase_08 AC 523 ms
17,952 KB
testcase_09 AC 1,652 ms
20,548 KB
testcase_10 AC 104 ms
15,296 KB
testcase_11 AC 108 ms
15,384 KB
testcase_12 AC 253 ms
16,608 KB
testcase_13 AC 1,274 ms
18,068 KB
testcase_14 AC 1,972 ms
18,388 KB
testcase_15 AC 116 ms
15,512 KB
testcase_16 AC 145 ms
15,848 KB
testcase_17 AC 104 ms
15,532 KB
testcase_18 AC 92 ms
15,176 KB
testcase_19 AC 1,414 ms
20,776 KB
testcase_20 AC 1,885 ms
21,076 KB
testcase_21 AC 154 ms
15,800 KB
testcase_22 AC 121 ms
15,468 KB
testcase_23 AC 127 ms
15,724 KB
testcase_24 AC 525 ms
18,328 KB
testcase_25 AC 961 ms
19,412 KB
testcase_26 AC 206 ms
16,400 KB
testcase_27 AC 169 ms
16,104 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

problem_num = gets.to_i
star_table = gets.split.map(&:to_i)

problem_table = {}
problem_num.times do |n|
  problem_table[(n+65).chr] = 1
end

score = Hash.new { |a, b| a[b] = Hash.new { |c, d| c[d] = 0 } }
score_total = Hash.new { |c, d| c[d] = 0 }
submit_order = {}

submit_num = gets.to_i
submit_num.times do |n|
  tmp = gets.split
  score[tmp[0]][tmp[1]] = (star_table[tmp[1].ord - 65] * 50 + 50 * star_table[tmp[1].ord - 65] / (0.8 + 0.2 * problem_table[tmp[1]])).floor
  score_total[tmp[0]] = score_total[tmp[0]] + score[tmp[0]][tmp[1]]
  submit_order[tmp[0]] = n
  problem_table[tmp[1]] += 1
end

score_total_desc = score_total.sort { |(k1, v1), (k2, v2)| v2 <=> v1 }

score_order = {}
score_total_desc.each_with_index do |(k1, v1), n1|
  num = 1
  score_total_desc.each_with_index do |(k2, v2), n2|
    if n1+1 != submit_order.size then
      if k1 == k2 then
        next
      else
        score_order[k1] = num
      end
    end

    if v1 < v2 then
      num += 1
      next
    elsif v1 > v2 then
      score_order[k1] = num
      break
    elsif  v1 == v2 then
      if submit_order[k1] > submit_order[k2] then
        num += 1
      end
    end
  end
  score_order[k1] = num
end

score_order_asc = score_order.sort { |(k1, v1), (k2, v2)| v1 <=> v2 }

ans = []
score_order_asc.each do |k, v|
  line = v.to_s + " " + k + " "
  problem_table.each_key do |t|
    line += score[k][t].to_s + " "
  end
  line += score_total[k].to_s
  ans << line
end

ans.each do |a|
  puts a
end
0