結果

問題 No.267 トランプソート
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-21 22:39:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 2,264 bytes
コンパイル時間 3,844 ms
コンパイル使用メモリ 79,204 KB
実行使用メモリ 56,408 KB
最終ジャッジ日時 2023-09-25 14:57:03
合計ジャッジ時間 7,930 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
53,888 KB
testcase_01 AC 127 ms
55,504 KB
testcase_02 AC 125 ms
55,700 KB
testcase_03 AC 128 ms
55,904 KB
testcase_04 AC 126 ms
55,760 KB
testcase_05 AC 127 ms
55,724 KB
testcase_06 AC 128 ms
55,824 KB
testcase_07 AC 126 ms
55,712 KB
testcase_08 AC 132 ms
56,060 KB
testcase_09 AC 132 ms
55,860 KB
testcase_10 AC 134 ms
55,864 KB
testcase_11 AC 132 ms
55,456 KB
testcase_12 AC 130 ms
56,312 KB
testcase_13 AC 131 ms
55,716 KB
testcase_14 AC 129 ms
55,912 KB
testcase_15 AC 131 ms
56,408 KB
testcase_16 AC 132 ms
56,020 KB
testcase_17 AC 131 ms
56,160 KB
testcase_18 AC 132 ms
55,752 KB
testcase_19 AC 131 ms
55,764 KB
testcase_20 AC 132 ms
55,740 KB
testcase_21 AC 131 ms
55,764 KB
testcase_22 AC 133 ms
55,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class No0267 {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();
		ArrayList<Integer> d = new ArrayList<>();
		ArrayList<Integer> c = new ArrayList<>();
		ArrayList<Integer> h = new ArrayList<>();
		ArrayList<Integer> s = new ArrayList<>();

		HashMap<Character, Integer> map = new HashMap<>();
		map.put('A',1);
		map.put('T',10);
		map.put('J',11);
		map.put('Q',12);
		map.put('K',13);

		for (int i=0; i<n; i++) {
			String str = in.next();
			char m = str.charAt(0);
			char x = str.charAt(1);
			if (m == 'D') {
				if ('2' <= x && x <= '9') d.add(x - '0');
				else d.add(map.get(x));
			}else if (m == 'C') {
				if ('2' <= x && x <= '9') c.add(x - '0');
				else c.add(map.get(x));
			}else if (m == 'H') {
				if ('2' <= x && x <= '9') h.add(x - '0');
				else h.add(map.get(x));
			}else {
				if ('2' <= x && x <= '9') s.add(x - '0');
				else s.add(map.get(x));
			}
		}

		HashMap<Integer,Character> map2 = new HashMap<>();
		map2.put(1,'A');
		map2.put(10,'T');
		map2.put(11,'J');
		map2.put(12,'Q');
		map2.put(13,'K');

		Collections.sort(d);
		Collections.sort(c);
		Collections.sort(h);
		Collections.sort(s);
		StringBuilder sb = new StringBuilder();
		for (int i : d) {
			sb.append("D");
			if (2 <= i && i <= 9) sb.append(i);
			else sb.append(map2.get(i));
			sb.append(" ");
		}
		for (int i : c) {
			sb.append("C");
			if (2 <= i && i <= 9) sb.append(i);
			else sb.append(map2.get(i));
			sb.append(" ");
		}
		for (int i : h) {
			sb.append("H");
			if (2 <= i && i <= 9) sb.append(i);
			else sb.append(map2.get(i));
			sb.append(" ");
		}
		for (int i : s) {
			sb.append("S");
			if (2 <= i && i <= 9) sb.append(i);
			else sb.append(map2.get(i));
			sb.append(" ");
		}
		sb.deleteCharAt(sb.length()-1);
		out.println(sb);
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}
0