結果

問題 No.267 トランプソート
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-15 13:37:01
言語 Ruby
(3.3.0)
結果
AC  
実行時間 86 ms / 1,000 ms
コード長 760 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 11,572 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-10-11 16:19:32
合計ジャッジ時間 3,213 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,176 KB
testcase_01 AC 80 ms
15,044 KB
testcase_02 AC 81 ms
15,108 KB
testcase_03 AC 81 ms
15,248 KB
testcase_04 AC 84 ms
15,036 KB
testcase_05 AC 82 ms
15,216 KB
testcase_06 AC 83 ms
15,304 KB
testcase_07 AC 82 ms
15,244 KB
testcase_08 AC 83 ms
15,312 KB
testcase_09 AC 85 ms
15,048 KB
testcase_10 AC 83 ms
15,172 KB
testcase_11 AC 84 ms
15,156 KB
testcase_12 AC 84 ms
15,320 KB
testcase_13 AC 83 ms
15,144 KB
testcase_14 AC 82 ms
15,328 KB
testcase_15 AC 85 ms
15,048 KB
testcase_16 AC 85 ms
15,248 KB
testcase_17 AC 86 ms
15,252 KB
testcase_18 AC 84 ms
15,160 KB
testcase_19 AC 84 ms
15,304 KB
testcase_20 AC 84 ms
15,292 KB
testcase_21 AC 83 ms
15,164 KB
testcase_22 AC 83 ms
15,244 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

mapping = Struct.new(:index, :value)
n = gets.to_i
t = gets.split
m = Array.new(n)
n.times do |i|
    value = 0
    if t[i][0] == "D"
        value += 0
    elsif t[i][0] == "C"
        value += 13
    elsif t[i][0] == "H"
        value += 13 * 2
    else
        value += 13 * 3
    end
    if t[i][1] == "A"
        value += 1
    elsif t[i][1] == "T"
        value += 10
    elsif t[i][1] == "J"
        value += 11
    elsif t[i][1] == "Q"
        value += 12
    elsif t[i][1] == "K"
        value += 13
    else
        value += t[i][1].to_i
    end
    m[i] = mapping.new(i, value)
end
m.sort! { |a, b| a.value <=> b.value }
m.length.times do |i|
    if i >= m.length - 1
        puts t[m[i].index]
        break
    end
    print t[m[i].index], " "
end
0