結果

問題 No.205 マージして辞書順最小
コンテスト
ユーザー mai
提出日時 2018-09-25 00:39:38
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
WA  
実行時間 -
コード長 407 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 40 ms
コンパイル使用メモリ 8,960 KB
実行使用メモリ 23,012 KB
最終ジャッジ日時 2026-04-11 20:43:46
合計ジャッジ時間 19,818 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 3 WA * 4 TLE * 1 -- * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:10: warning: assigned but unused variable - item
Syntax OK

ソースコード

diff #
raw source code

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