結果

問題 No.267 トランプソート
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-09 03:37:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 172 ms / 1,000 ms
コード長 1,634 bytes
コンパイル時間 2,464 ms
コンパイル使用メモリ 76,456 KB
実行使用メモリ 59,204 KB
最終ジャッジ日時 2023-08-19 03:03:13
合計ジャッジ時間 8,156 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
56,640 KB
testcase_01 AC 159 ms
56,628 KB
testcase_02 AC 159 ms
56,856 KB
testcase_03 AC 160 ms
56,988 KB
testcase_04 AC 155 ms
56,776 KB
testcase_05 AC 155 ms
56,912 KB
testcase_06 AC 161 ms
57,248 KB
testcase_07 AC 156 ms
56,792 KB
testcase_08 AC 167 ms
56,920 KB
testcase_09 AC 168 ms
57,076 KB
testcase_10 AC 172 ms
59,204 KB
testcase_11 AC 168 ms
57,132 KB
testcase_12 AC 169 ms
57,164 KB
testcase_13 AC 169 ms
57,080 KB
testcase_14 AC 166 ms
57,024 KB
testcase_15 AC 167 ms
57,152 KB
testcase_16 AC 167 ms
57,000 KB
testcase_17 AC 167 ms
57,128 KB
testcase_18 AC 169 ms
56,928 KB
testcase_19 AC 168 ms
57,032 KB
testcase_20 AC 170 ms
56,716 KB
testcase_21 AC 172 ms
56,844 KB
testcase_22 AC 169 ms
57,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] mn = new int [N];
        for(int i=0; i<N; i++){
            String tmp=sc.next();
            int t1=tmp.charAt(0);
            if(t1=='C'){
                mn[i]+=100;
            }else if(t1=='H'){
                mn[i]+=200;
            }else if(t1=='S'){
                mn[i]+=300;
            }
            int t2=tmp.charAt(1);
            if('2'<=t2&&t2<='9'){
                mn[i]+=(t2-'0');
            }else if(t2=='T'){
                mn[i]+=10;
            }else if(t2=='J'){
                mn[i]+=11;
            }else if(t2=='Q'){
                mn[i]+=12;
            }else if(t2=='K'){
                mn[i]+=13;
            }
        }
        Arrays.sort(mn);
        for(int i=0; i<N; i++){
            String m="";
            String n="";
            int t1=mn[i]/100;
            if(t1==0){
                m="D";
            }else if(t1==1){
                m="C";
            }else if(t1==2){
                m="H";
            }else if(t1==3){
                m="S";
            }
            int t2=mn[i]%100;
            if(t2==0){
                n="A";
            }else if(t2==10){
                n="T";
            }else if(t2==11){
                n="J";
            }else if(t2==12){
                n="Q";
            }else if(t2==13){
                n="K";
            }else{
                n=String.valueOf(t2);
            }
            System.out.print(m+n+" ");
        }
        System.out.println();
    }
}
0