結果
問題 |
No.267 トランプソート
|
ユーザー |
![]() |
提出日時 | 2015-12-08 02:02:56 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 31 ms / 1,000 ms |
コード長 | 1,170 bytes |
コンパイル時間 | 1,160 ms |
コンパイル使用メモリ | 113,328 KB |
実行使用メモリ | 18,816 KB |
最終ジャッジ日時 | 2024-09-14 19:01:58 |
合計ジャッジ時間 | 2,673 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace No267 { class MainClass { private class CustomComparer : IComparer<string> { private readonly IDictionary<char, int> orders = new Dictionary<char, int>(); private readonly IDictionary<char, int> numbers = new Dictionary<char, int>(); public CustomComparer() { orders.Add('D', 1); orders.Add('C', 2); orders.Add('H', 3); orders.Add('S', 4); for(char c = '2';c <= '9';c++) { numbers.Add(c, c-'0'); } numbers.Add('A', 1); numbers.Add('T', 10); numbers.Add('J', 11); numbers.Add('Q', 12); numbers.Add('K', 13); } #region IComparer implementation int IComparer<string>.Compare (string x, string y) { if (orders [x [0]] == orders [y [0]]) { return numbers[x[1]] - numbers[y[1]]; } return orders[x[0]] - orders[y[0]]; } #endregion } public static void Main (string[] args) { var n = Console.ReadLine (); var keys = Console.ReadLine ().Split(' ').ToList(); keys.Sort (new CustomComparer ()); Console.WriteLine(string.Join(" ", keys)); } } }