結果

問題 No.39 桁の数字を入れ替え
コンテスト
ユーザー tenten
提出日時 2020-11-17 08:57:27
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 54 ms / 5,000 ms
+ 473µs
コード長 691 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,331 ms
コンパイル使用メモリ 84,100 KB
実行使用メモリ 42,976 KB
最終ジャッジ日時 2026-08-23 16:19:54
合計ジャッジ時間 3,679 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        for (int i = 0; i < arr.length - 1; i++) {
            int max = arr[i];
            int idx = i;
            for (int j = i + 1; j < arr.length; j++) {
                if (max <= arr[j]) {
                    idx = j;
                    max = arr[j];
                }
            }
            if (arr[i] < max) {
                char tmp = arr[idx];
                arr[idx] = arr[i];
                arr[i] = tmp;
                break;
            }
        }
        System.out.println(arr);
    }
}
0