結果

問題 No.267 トランプソート
ユーザー nanophoto12nanophoto12
提出日時 2015-12-08 02:02:56
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 62 ms / 1,000 ms
コード長 1,170 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 105,616 KB
実行使用メモリ 23,388 KB
最終ジャッジ日時 2023-10-12 20:42:04
合計ジャッジ時間 5,118 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,584 KB
testcase_01 AC 60 ms
21,252 KB
testcase_02 AC 59 ms
19,304 KB
testcase_03 AC 56 ms
23,388 KB
testcase_04 AC 60 ms
21,364 KB
testcase_05 AC 60 ms
21,188 KB
testcase_06 AC 60 ms
21,312 KB
testcase_07 AC 60 ms
23,356 KB
testcase_08 AC 61 ms
23,256 KB
testcase_09 AC 61 ms
23,248 KB
testcase_10 AC 61 ms
19,412 KB
testcase_11 AC 61 ms
23,316 KB
testcase_12 AC 60 ms
21,328 KB
testcase_13 AC 60 ms
21,264 KB
testcase_14 AC 61 ms
21,312 KB
testcase_15 AC 60 ms
21,276 KB
testcase_16 AC 60 ms
21,392 KB
testcase_17 AC 60 ms
21,380 KB
testcase_18 AC 61 ms
21,256 KB
testcase_19 AC 61 ms
23,304 KB
testcase_20 AC 62 ms
23,308 KB
testcase_21 AC 61 ms
21,304 KB
testcase_22 AC 61 ms
23,296 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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));
		}
	}
}
0