結果

問題 No.39 桁の数字を入れ替え
ユーザー ルッツファンルッツファン
提出日時 2015-11-28 08:43:40
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,323 bytes
コンパイル時間 3,291 ms
コンパイル使用メモリ 84,584 KB
実行使用メモリ 55,436 KB
最終ジャッジ日時 2023-10-12 05:05:31
合計ジャッジ時間 5,954 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
52,408 KB
testcase_01 AC 93 ms
52,412 KB
testcase_02 AC 85 ms
53,400 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 83 ms
52,508 KB
testcase_07 AC 83 ms
52,440 KB
testcase_08 AC 82 ms
50,612 KB
testcase_09 AC 82 ms
53,460 KB
testcase_10 AC 90 ms
53,500 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 87 ms
52,256 KB
testcase_16 AC 83 ms
52,332 KB
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
				}
			}
		}
		
		String asdf = "";
		String as = "";
		for(int i= 0;i<tmps.length;i++){
			if(tmpq[i] != tmps[i]){
				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