結果
| 問題 | 
                            No.113 宝探し
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-01-29 23:30:17 | 
| 言語 | C#(csc)  (csc 3.9.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 32 ms / 5,000 ms | 
| コード長 | 820 bytes | 
| コンパイル時間 | 788 ms | 
| コンパイル使用メモリ | 106,496 KB | 
| 実行使用メモリ | 20,352 KB | 
| 最終ジャッジ日時 | 2024-11-16 22:00:40 | 
| 合計ジャッジ時間 | 2,377 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 23 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
class Program
{
    const char North = 'N';
    const char East = 'E';
    const char West = 'W';
    const char South = 'S';
    static void Main(string[] args)
    {
        var line = Console.ReadLine().ToCharArray().OrderBy(x => x).ToList();
        int nCnt = line.Count(x => x == North);
        int eCnt = line.Count(x => x == East);
        int wCnt = line.Count(x => x == West);
        int sCnt = line.Count(x => x == South);
        int horizontal = Math.Abs(nCnt - sCnt);
        int vartical = Math.Abs(eCnt - wCnt);
        var dist = Math.Sqrt(
                        Math.Pow(horizontal, 2) +
                        Math.Pow(vartical, 2) 
                   );
        Console.WriteLine(Math.Round(dist,5, MidpointRounding.AwayFromZero));
        return;
    }
}