結果

問題 No.1708 Quality of Contest
ユーザー shimatshimat
提出日時 2021-10-26 19:50:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 743 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 64 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 51,768 KB
最終ジャッジ日時 2024-04-15 18:59:53
合計ジャッジ時間 14,520 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
12,288 KB
testcase_01 AC 87 ms
12,416 KB
testcase_02 AC 88 ms
12,288 KB
testcase_03 AC 98 ms
12,800 KB
testcase_04 AC 95 ms
12,800 KB
testcase_05 AC 98 ms
12,800 KB
testcase_06 AC 93 ms
12,928 KB
testcase_07 AC 95 ms
12,672 KB
testcase_08 AC 82 ms
12,416 KB
testcase_09 AC 696 ms
51,768 KB
testcase_10 AC 668 ms
41,268 KB
testcase_11 AC 716 ms
44,764 KB
testcase_12 AC 707 ms
46,080 KB
testcase_13 AC 706 ms
46,148 KB
testcase_14 AC 713 ms
46,396 KB
testcase_15 AC 702 ms
47,416 KB
testcase_16 AC 739 ms
47,300 KB
testcase_17 AC 702 ms
46,676 KB
testcase_18 AC 723 ms
46,788 KB
testcase_19 AC 726 ms
46,816 KB
testcase_20 AC 726 ms
46,560 KB
testcase_21 AC 743 ms
46,684 KB
testcase_22 AC 726 ms
46,464 KB
testcase_23 AC 740 ms
47,320 KB
testcase_24 AC 716 ms
41,412 KB
testcase_25 AC 713 ms
41,536 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'set'

N, M, X = gets.split.map(&:to_i)
AB = N.times.map { gets.split.map(&:to_i) }
K = gets.to_i
C = gets.split.map(&:to_i)

ab = AB.sort_by{|ab| -ab[0]}

used = Set.new
ans = []
ab.each do |n|
  if used.add?(n[1])
    ans << n[0] + X
  else
    ans << n[0]
  end
end

ans.sort_by!{|x| -x}

ans2 = [0]
now = 0
ans.each do |x|
  now += x
  ans2 << now
end

p K.times.sum{|k| ans2[C[k]]}
0