結果

問題 No.267 トランプソート
ユーザー kou6839kou6839
提出日時 2015-08-22 19:00:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 203 ms / 1,000 ms
コード長 894 bytes
コンパイル時間 4,411 ms
コンパイル使用メモリ 87,572 KB
実行使用メモリ 57,432 KB
最終ジャッジ日時 2023-09-25 16:13:59
合計ジャッジ時間 10,289 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 182 ms
56,868 KB
testcase_01 AC 179 ms
55,064 KB
testcase_02 AC 181 ms
57,060 KB
testcase_03 AC 183 ms
57,156 KB
testcase_04 AC 181 ms
56,876 KB
testcase_05 AC 185 ms
57,284 KB
testcase_06 AC 185 ms
57,104 KB
testcase_07 AC 184 ms
57,064 KB
testcase_08 AC 189 ms
57,076 KB
testcase_09 AC 188 ms
57,136 KB
testcase_10 AC 197 ms
56,836 KB
testcase_11 AC 186 ms
56,744 KB
testcase_12 AC 182 ms
57,116 KB
testcase_13 AC 187 ms
57,076 KB
testcase_14 AC 186 ms
56,900 KB
testcase_15 AC 203 ms
56,808 KB
testcase_16 AC 190 ms
57,108 KB
testcase_17 AC 195 ms
56,896 KB
testcase_18 AC 182 ms
57,124 KB
testcase_19 AC 181 ms
54,968 KB
testcase_20 AC 184 ms
57,036 KB
testcase_21 AC 189 ms
56,796 KB
testcase_22 AC 186 ms
57,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;


public class Main {
	static char[] mark ={'D','C','H','S'};
	static char[] number ={'A','2','3','4','5','6','7','8','9','T','J','Q','K'};
	static int to_int(String string){ 
		int tmp=0;
		for(int i=0;i<4;i++){
			if(string.charAt(0)==mark[i]) tmp+=i*13;
		}
		for(int i=0;i<13;i++){
			if(string.charAt(1)==number[i])tmp+=i+1;
		}
		return tmp;
	}
	static String to_string(int a){
		String ret = "";
		ret+=mark[(a-1)/13];
		ret+=number[a-((a-1)/13)*13-1];
		return ret;
	}
    public static void main(String[] args){
        // TODO 自動生成されたメソッド・スタブ
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] in = new int[N];
    	for(int i=0;i<N;i++) in[i]=to_int(sc.next());
    	Arrays.sort(in);
    	String ans = "";
    	for(int i=0;i<N;i++) ans+=to_string(in[i])+" ";
    	System.out.println(ans.trim());
    }
}
0