結果
問題 | No.927 Second Permutation |
ユーザー | htensai |
提出日時 | 2019-12-07 11:02:06 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 652 bytes |
コンパイル時間 | 2,059 ms |
コンパイル使用メモリ | 72,056 KB |
実行使用メモリ | 59,060 KB |
最終ジャッジ日時 | 2023-08-26 05:17:43 |
合計ジャッジ時間 | 8,957 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 118 ms
56,264 KB |
testcase_01 | AC | 118 ms
55,560 KB |
testcase_02 | AC | 119 ms
55,972 KB |
testcase_03 | AC | 118 ms
55,972 KB |
testcase_04 | AC | 119 ms
56,064 KB |
testcase_05 | AC | 119 ms
55,712 KB |
testcase_06 | AC | 119 ms
55,676 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 207 ms
56,512 KB |
testcase_25 | AC | 194 ms
56,460 KB |
testcase_26 | AC | 178 ms
56,996 KB |
testcase_27 | AC | 188 ms
56,660 KB |
testcase_28 | AC | 209 ms
56,160 KB |
testcase_29 | AC | 200 ms
56,904 KB |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); char[] arr = sc.next().toCharArray(); int length = arr.length; Arrays.sort(arr); char max = arr[length - 1]; for (int i = 0; i < length - 1; i++) { if (arr[i] == max) { break; } if (arr[i] == '0' || arr[i] == arr[i + 1]) { continue; } char tmp = arr[i]; arr[i] = arr[i + 1]; arr[i + 1] = tmp; StringBuilder sb = new StringBuilder(new String(arr)); sb.reverse(); System.out.println(sb); return; } System.out.println(-1); } }