結果

問題 No.39 桁の数字を入れ替え
ユーザー ルッツファンルッツファン
提出日時 2015-11-28 08:46:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 98 ms / 5,000 ms
コード長 1,384 bytes
コンパイル時間 3,632 ms
コンパイル使用メモリ 81,104 KB
実行使用メモリ 53,176 KB
最終ジャッジ日時 2024-04-10 05:15:27
合計ジャッジ時間 6,004 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
51,460 KB
testcase_01 AC 86 ms
50,992 KB
testcase_02 AC 86 ms
51,416 KB
testcase_03 AC 84 ms
51,036 KB
testcase_04 AC 85 ms
51,416 KB
testcase_05 AC 84 ms
51,312 KB
testcase_06 AC 84 ms
51,428 KB
testcase_07 AC 96 ms
52,904 KB
testcase_08 AC 86 ms
51,192 KB
testcase_09 AC 84 ms
53,176 KB
testcase_10 AC 86 ms
51,492 KB
testcase_11 AC 84 ms
51,144 KB
testcase_12 AC 86 ms
50,920 KB
testcase_13 AC 97 ms
52,964 KB
testcase_14 AC 84 ms
51,512 KB
testcase_15 AC 84 ms
51,516 KB
testcase_16 AC 92 ms
51,192 KB
testcase_17 AC 87 ms
51,484 KB
testcase_18 AC 98 ms
52,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class yukicoder014 {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;
		
		try {
			tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
		}
		
		
		
		char[] tmpq = tes.toCharArray();
		
		char[] tmps = tes.toCharArray();
		char jie = 0;
		for(int i=0;i<tmps.length;i++){
			for(int j=0;j<tmps.length;j++){
				if(tmps[i]  > tmps[j]){
					jie = tmps[i];
					tmps[i] = tmps[j];
					tmps[j] = jie;
				}
			}
		}
		
		int rrr = 0;
		String asdf = "";
		String as = "";
		for(int i= 0;i<tmps.length;i++){
			if(rrr != 1 &&tmpq[i] != tmps[i]){
				rrr = 1;
			}
			if(rrr == 1){
				asdf = asdf + tmpq[i];
			}else{
				as = as + tmpq[i];
			}
		}
		
		char[] tmp = asdf.toCharArray();
		
		char s = '1';
		int num = -1;
		
		for(int i = 0;i<tmp.length;i++){
			if(tmp[i] >= s){
				s = tmp[i];
				num = i;
			}
		}
		char aaa = 0;
		
		
		for(int i = 0;i<tmp.length;i++){
			if(num == 0){
				break;
			}
			if(tmp[i] < s){
				aaa = tmp[i];
				
				tmp[i] = s;
				
				tmp[num] = aaa;
				
				
				break;
			}
		}
		
		
		
		
		
		System.out.println(as+String.copyValueOf(tmp));
		
		
		
	}

}
0