結果
問題 | No.267 トランプソート |
ユーザー | kenji_shioya |
提出日時 | 2016-06-16 02:47:22 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 160 ms / 1,000 ms |
コード長 | 2,354 bytes |
コンパイル時間 | 3,638 ms |
コンパイル使用メモリ | 80,836 KB |
実行使用メモリ | 55,316 KB |
最終ジャッジ日時 | 2024-04-17 22:49:41 |
合計ジャッジ時間 | 7,831 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 148 ms
54,868 KB |
testcase_01 | AC | 142 ms
54,652 KB |
testcase_02 | AC | 135 ms
54,832 KB |
testcase_03 | AC | 150 ms
55,136 KB |
testcase_04 | AC | 148 ms
55,008 KB |
testcase_05 | AC | 136 ms
54,784 KB |
testcase_06 | AC | 153 ms
55,064 KB |
testcase_07 | AC | 154 ms
54,692 KB |
testcase_08 | AC | 141 ms
54,716 KB |
testcase_09 | AC | 156 ms
54,960 KB |
testcase_10 | AC | 157 ms
55,196 KB |
testcase_11 | AC | 153 ms
55,116 KB |
testcase_12 | AC | 142 ms
54,752 KB |
testcase_13 | AC | 147 ms
55,132 KB |
testcase_14 | AC | 148 ms
55,040 KB |
testcase_15 | AC | 137 ms
55,208 KB |
testcase_16 | AC | 137 ms
55,140 KB |
testcase_17 | AC | 135 ms
54,732 KB |
testcase_18 | AC | 160 ms
54,644 KB |
testcase_19 | AC | 133 ms
55,316 KB |
testcase_20 | AC | 149 ms
55,272 KB |
testcase_21 | AC | 143 ms
54,532 KB |
testcase_22 | AC | 146 ms
55,232 KB |
ソースコード
import java.util.*; public class Exercise86{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); ArrayList<ArrayList<Integer>> array = new ArrayList<ArrayList<Integer>>(); for(int i = 0; i < 4; i++){ array.add(new ArrayList<Integer>()); } int n = sc.nextInt(); for(int i = 0; i < n; i++){ String x = sc.next(); if(x.contains("D")){ x = changeNum(x); x = x.replace("D", ""); array.get(0).add(Integer.parseInt(x)); }else if(x.contains("C")){ x = changeNum(x); x = x.replace("C", ""); array.get(1).add(Integer.parseInt(x)); }else if(x.contains("H")){ x = changeNum(x); x = x.replace("H", ""); array.get(2).add(Integer.parseInt(x)); }else if(x.contains("S")){ x = changeNum(x); x = x.replace("S", ""); array.get(3).add(Integer.parseInt(x)); } } for(int i = 0; i < array.size(); i++){ Collections.sort(array.get(i)); } String answer = ""; for(int i = 0; i < array.size(); i++){ for(int j = 0; j < array.get(i).size(); j++){ String y = changeNum(String.valueOf(array.get(i).get(j))); if(i == 0){ answer += "D"; }else if(i == 1){ answer += "C"; }else if(i == 2){ answer += "H"; }else if(i == 3){ answer += "S"; } answer += y + " "; } } System.out.println(answer); } private static String changeNum(String x){ if (x.contains("T")){ x = x.replace("T", "10"); return x; }else if(x.contains("J")){ x = x.replace("J", "11"); return x; }else if(x.contains("Q")){ x = x.replace("Q", "12"); return x; }else if(x.contains("K")){ x = x.replace("K", "13"); return x; }else if(x.contains("A")){ x = x.replace("A", "1"); return x; }else if(x.contains("10")){ x = x.replace("10", "T"); return x; }else if(x.contains("11")){ x = x.replace("11", "J"); return x; }else if(x.contains("12")){ x = x.replace("12", "Q"); return x; }else if(x.contains("13")){ x = x.replace("13", "K"); return x; }else if(x.contains("1")){ x = x.replace("1", "A"); return x; } return x; } }