結果
問題 | No.267 トランプソート |
ユーザー | YamaKasa |
提出日時 | 2018-09-08 12:15:51 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 142 ms / 1,000 ms |
コード長 | 2,802 bytes |
コンパイル時間 | 2,903 ms |
コンパイル使用メモリ | 80,416 KB |
実行使用メモリ | 56,596 KB |
最終ジャッジ日時 | 2023-08-22 00:21:20 |
合計ジャッジ時間 | 7,676 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 127 ms
56,220 KB |
testcase_01 | AC | 126 ms
56,008 KB |
testcase_02 | AC | 129 ms
55,556 KB |
testcase_03 | AC | 127 ms
56,092 KB |
testcase_04 | AC | 129 ms
56,072 KB |
testcase_05 | AC | 128 ms
56,316 KB |
testcase_06 | AC | 126 ms
55,992 KB |
testcase_07 | AC | 129 ms
55,544 KB |
testcase_08 | AC | 140 ms
55,984 KB |
testcase_09 | AC | 141 ms
55,908 KB |
testcase_10 | AC | 140 ms
56,180 KB |
testcase_11 | AC | 141 ms
56,100 KB |
testcase_12 | AC | 141 ms
56,328 KB |
testcase_13 | AC | 140 ms
56,032 KB |
testcase_14 | AC | 138 ms
56,024 KB |
testcase_15 | AC | 138 ms
55,964 KB |
testcase_16 | AC | 141 ms
55,980 KB |
testcase_17 | AC | 140 ms
55,960 KB |
testcase_18 | AC | 139 ms
56,260 KB |
testcase_19 | AC | 142 ms
56,596 KB |
testcase_20 | AC | 141 ms
56,148 KB |
testcase_21 | AC | 140 ms
56,112 KB |
testcase_22 | AC | 142 ms
56,128 KB |
ソースコード
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); List<Integer> listD = new ArrayList<Integer>(); List<Integer> listC = new ArrayList<Integer>(); List<Integer> listH = new ArrayList<Integer>(); List<Integer> listS = new ArrayList<Integer>(); for(int i = 0; i < N; i++) { String s = scan.next(); String m = s.substring(0, 1); String n = s.substring(1, 2); int t; if(n.equals("A")) { t = 1; }else if(n.equals("T")) { t = 10; }else if(n.equals("J")) { t = 11; }else if(n.equals("Q")) { t = 12; }else if(n.equals("K")) { t = 13; }else { t = Integer.parseInt(n); } if(m.equals("D")) { listD.add(t); }else if(m.equals("C")) { listC.add(t); }else if(m.equals("H")) { listH.add(t); }else { listS.add(t); } } scan.close(); int l = listD.size() + listC.size() + listH.size() + listS.size(); String[] ans = new String[l]; Collections.sort(listD); Collections.sort(listC); Collections.sort(listH); Collections.sort(listS); int index = 0; for(int i = 0; i < listD.size(); i++) { int k = listD.get(i); if(k == 1) { ans[index] = "DA"; }else if(k == 10){ ans[index] = "DT"; }else if(k == 11) { ans[index] = "DJ"; }else if(k == 12) { ans[index] = "DQ"; }else if(k == 13){ ans[index] = "DK"; }else { ans[index] = "D" + Integer.toString(k); } index ++; } for(int i = 0; i < listC.size(); i++) { int k = listC.get(i); if(k == 1) { ans[index] = "CA"; }else if(k == 10){ ans[index] = "CT"; }else if(k == 11) { ans[index] = "CJ"; }else if(k == 12) { ans[index] = "CQ"; }else if(k == 13){ ans[index] = "CK"; }else { ans[index] = "C" + Integer.toString(k); } index ++; } for(int i = 0; i < listH.size(); i++) { int k = listH.get(i); if(k == 1) { ans[index] = "HA"; }else if(k == 10){ ans[index] = "HT"; }else if(k == 11) { ans[index] = "HJ"; }else if(k == 12) { ans[index] = "HQ"; }else if(k == 13){ ans[index] = "HK"; }else { ans[index] = "H" + Integer.toString(k); } index ++; } for(int i = 0; i < listS.size(); i++) { int k = listS.get(i); if(k == 1) { ans[index] = "SA"; }else if(k == 10){ ans[index] = "ST"; }else if(k == 11) { ans[index] = "SJ"; }else if(k == 12) { ans[index] = "SQ"; }else if(k == 13){ ans[index] = "SK"; }else { ans[index] = "S" + Integer.toString(k); } index ++; } for(int i = 0; i < l - 1; i++) { System.out.print(ans[i] + " "); } System.out.println(ans[l - 1]); } }