結果

問題 No.205 マージして辞書順最小
ユーザー maimai
提出日時 2018-09-25 00:39:38
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 17,324 KB
最終ジャッジ日時 2023-10-24 22:23:10
合計ジャッジ時間 24,444 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
16,132 KB
testcase_01 AC 95 ms
16,164 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 141 ms
16,160 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:10: warning: assigned but unused variable - item
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i); end

strs_t = gets.to_i.times.map{gets.chomp}

best = 'z'*250
400.times do
    ans = ''
    strs = strs_t.map{|l| l.chars}
    while !strs.empty?
        item, i = strs.each_with_index.min{|a,b| a[0][0] == b[0][0] ? rand(-1..1) : a[0][0] <=> b[0][0]}
        ans << strs[i].shift
        strs.delete_at(i) if strs[i].empty?
    end
    best = [ans,best].min
end

puts best
0