結果

問題 No.256 桁の数字を入れ替え (2)
ユーザー threepipes_sthreepipes_s
提出日時 2015-10-05 19:22:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 2,311 bytes
コンパイル時間 3,391 ms
コンパイル使用メモリ 76,780 KB
実行使用メモリ 52,152 KB
最終ジャッジ日時 2023-09-27 07:02:44
合計ジャッジ時間 4,356 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
49,552 KB
testcase_01 AC 39 ms
49,288 KB
testcase_02 AC 91 ms
52,040 KB
testcase_03 AC 92 ms
52,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashMap;

public class Main{
	public static void main(String[] args){
		try {
			(new Solve()).solve();
		} catch (NumberFormatException | IOException e) {
			e.printStackTrace();
		}
	}
}

class Solve{
	void solve() throws NumberFormatException, IOException{
		final ContestScanner in = new ContestScanner();
		char[] s = in.nextToken().toCharArray();
		Arrays.sort(s);
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<s.length; i++){
			sb.append(s[s.length-i-1]);
		}
		System.out.println(sb.toString());
	}
}

class MultiSet<T> extends HashMap<T, Integer>{
	@Override
	public Integer get(Object key) {
		if(this.containsKey(key)) return super.get(key);
		return 0;
	}
	public void add(T key){
		if(this.containsKey(key)) super.put(key, super.get(key)+1);
		else super.put(key, 1);
	}
	public void add(T key, int val){
		if(this.containsKey(key)) super.put(key, super.get(key)+val);
		else super.put(key, val);
	}
}

class ContestWriter{
	private PrintWriter out;
	public ContestWriter(String filename) throws IOException{
		out = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
	}
	public ContestWriter() throws IOException{out = new PrintWriter(System.out);}
	public void println(String str){out.println(str);}
	public void print(String str){out.print(str);}
	public void close(){out.close();}
}

class ContestScanner{
	BufferedReader reader;
	String[] line;
	int idx;
	public ContestScanner() throws FileNotFoundException{
		reader = new BufferedReader(new InputStreamReader(System.in));
	}
	
	public String nextToken() throws IOException{
		if(line == null || line.length <= idx){
			line = reader.readLine().trim().split(" ");
			idx = 0;
		}
		return line[idx++];
	}
	
	public long nextLong() throws IOException, NumberFormatException{
		return Long.parseLong(nextToken());
	}
	
	public int nextInt() throws NumberFormatException, IOException{
		return (int)nextLong();
	}
	
	public double nextDouble() throws NumberFormatException, IOException{
		return Double.parseDouble(nextToken());
	}
}
0