結果
問題 |
No.927 Second Permutation
|
ユーザー |
|
提出日時 | 2021-06-28 05:19:44 |
言語 | Swift (6.0.3) |
結果 |
WA
|
実行時間 | - |
コード長 | 387 bytes |
コンパイル時間 | 1,770 ms |
コンパイル使用メモリ | 134,300 KB |
実行使用メモリ | 16,240 KB |
最終ジャッジ日時 | 2024-06-25 11:59:25 |
合計ジャッジ時間 | 5,772 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 1 TLE * 1 -- * 21 |
ソースコード
var l = Array(String(readLine()!)).sorted(by: >) var n = 0 var s = Set(l) if s.count < 2 || (s.count == 2 && l.contains("0")){ print(-1) }else{ let m = Int(l.map{String($0)}.joined())! for i in [Int](1..<l.count).reversed(){ (l[i-1],l[i]) = (l[i],l[i-1]) n = Int(l.map{String($0)}.joined())! if m != n{ break } } print(n) }