結果

問題 No.927 Second Permutation
ユーザー kyo1kyo1
提出日時 2020-08-13 07:25:31
言語 Ruby
(3.3.0)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 243 bytes
コンパイル時間 33 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 23,808 KB
最終ジャッジ日時 2024-04-18 01:14:46
合計ジャッジ時間 5,328 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
12,160 KB
testcase_01 AC 74 ms
12,160 KB
testcase_02 AC 73 ms
12,160 KB
testcase_03 AC 77 ms
12,160 KB
testcase_04 AC 78 ms
12,160 KB
testcase_05 AC 78 ms
12,160 KB
testcase_06 AC 74 ms
12,160 KB
testcase_07 AC 75 ms
12,288 KB
testcase_08 AC 113 ms
15,488 KB
testcase_09 AC 77 ms
12,288 KB
testcase_10 AC 142 ms
16,204 KB
testcase_11 AC 217 ms
22,528 KB
testcase_12 AC 127 ms
16,000 KB
testcase_13 AC 79 ms
12,544 KB
testcase_14 AC 146 ms
19,072 KB
testcase_15 AC 123 ms
15,872 KB
testcase_16 AC 234 ms
23,680 KB
testcase_17 AC 236 ms
23,808 KB
testcase_18 AC 244 ms
23,680 KB
testcase_19 AC 236 ms
23,680 KB
testcase_20 AC 235 ms
23,680 KB
testcase_21 AC 234 ms
23,680 KB
testcase_22 AC 239 ms
23,680 KB
testcase_23 AC 233 ms
23,808 KB
testcase_24 AC 138 ms
23,168 KB
testcase_25 AC 119 ms
19,712 KB
testcase_26 AC 108 ms
15,744 KB
testcase_27 AC 106 ms
15,744 KB
testcase_28 AC 157 ms
22,656 KB
testcase_29 AC 146 ms
20,864 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s = gets.chomp.chars.sort.reverse.join
t = s.reverse.chars

(t.size - 1).times do |i|
  if t[i] != t[i + 1]
    t[i], t[i + 1] = t[i + 1], t[i]
    break
  end
end

t = t.join.reverse

if s == t || t.to_i.to_s != t
  puts(-1)
elsif puts t
end
0