結果
| 問題 |
No.927 Second Permutation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-11-30 21:23:34 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 2,000 ms |
| コード長 | 339 bytes |
| コンパイル時間 | 278 ms |
| コンパイル使用メモリ | 6,816 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 03:35:14 |
| 合計ジャッジ時間 | 1,977 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
local s = io.read()
local n = #s
local t = {}
for i = 1, n do
t[i] = tonumber(s:sub(i, i))
end
table.sort(t, function(a, b) return a > b end)
if t[2] == 0 or t[1] == t[n] then
print(-1)
else
for i = n, 2, -1 do
if t[i] ~= t[i - 1] then
t[i], t[i - 1] = t[i - 1], t[i]
break
end
end
print(table.concat(t))
end