結果

問題 No.256 桁の数字を入れ替え (2)
ユーザー ぴろずぴろず
提出日時 2015-07-31 22:27:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 531 bytes
コンパイル時間 1,886 ms
コンパイル使用メモリ 72,200 KB
実行使用メモリ 56,656 KB
最終ジャッジ日時 2023-09-24 22:48:54
合計ジャッジ時間 3,207 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,756 KB
testcase_01 AC 121 ms
55,932 KB
testcase_02 AC 217 ms
56,356 KB
testcase_03 AC 227 ms
56,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no256;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int l = s.length;
		int[] itr = new int[10];
		LOOP: for(int i=0;i<l;i++) {
			for(int j=9;j>=0;j--) {
				itr[j] = Math.max(i, itr[j]);
				for(;itr[j]<l;itr[j]++) {
					if (s[itr[j]] == '0' + j) {
						char temp = s[i];
						s[i] = s[itr[j]];
						s[itr[j]] = temp;
						continue LOOP;
					}
				}
			}
		}
		System.out.println(s);
	}

}
0