結果
問題 | No.927 Second Permutation |
ユーザー | htensai |
提出日時 | 2019-12-07 11:01:19 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 628 bytes |
コンパイル時間 | 1,875 ms |
コンパイル使用メモリ | 71,848 KB |
実行使用メモリ | 61,076 KB |
最終ジャッジ日時 | 2023-08-26 05:16:40 |
合計ジャッジ時間 | 8,256 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 105 ms
55,756 KB |
testcase_01 | AC | 105 ms
55,604 KB |
testcase_02 | AC | 104 ms
55,260 KB |
testcase_03 | AC | 104 ms
55,520 KB |
testcase_04 | AC | 102 ms
55,648 KB |
testcase_05 | AC | 104 ms
55,676 KB |
testcase_06 | AC | 104 ms
55,524 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 | 174 ms
56,420 KB |
testcase_25 | AC | 158 ms
55,824 KB |
testcase_26 | AC | 155 ms
56,276 KB |
testcase_27 | AC | 148 ms
56,272 KB |
testcase_28 | AC | 179 ms
55,824 KB |
testcase_29 | AC | 174 ms
54,820 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') { 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); } }