結果
問題 | No.267 トランプソート |
ユーザー |
![]() |
提出日時 | 2015-08-21 22:30:29 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 144 ms / 1,000 ms |
コード長 | 1,300 bytes |
コンパイル時間 | 2,249 ms |
コンパイル使用メモリ | 79,920 KB |
実行使用メモリ | 41,784 KB |
最終ジャッジ日時 | 2024-07-18 11:36:31 |
合計ジャッジ時間 | 6,180 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
import java.util.*;import java.io.*;import java.math.*;public class Main {public static void main(String[] args) {char[] M = new char[] {'D','C','H','S'};Scanner sc = new Scanner(System.in);int n = sc.nextInt();Data[] list = new Data[n];for(int i = 0; i < n; i++) {String in = sc.next();int m = 0;char c = in.charAt(0);switch(c) {case 'D': m = 0; break;case 'C': m = 1; break;case 'H': m = 2; break;case 'S': m = 3; break;}int num = 0;if(in.substring(1).equals("A")) num = 1;else if(in.substring(1).equals("T")) num = 10;else if(in.substring(1).equals("J")) num = 11;else if(in.substring(1).equals("Q")) num = 12;else if(in.substring(1).equals("K")) num = 13;else num = Integer.parseInt(in.substring(1));list[i] = new Data(m,num,in);}Arrays.sort(list);System.out.print(list[0].out);for(int i = 1; i < n; i++) {System.out.print(" " + list[i].out);}System.out.println();}static class Data implements Comparable<Data> {int mark;int number;String out;Data(int a, int b,String c) {mark = a;number = b;out = c;}@Overridepublic int compareTo(Data o) {if(o.mark == this.mark) return this.number - o.number;return this.mark - o.mark;}}}