結果

問題 No.349 干支の置き物
ユーザー 14番
提出日時 2016-05-26 03:25:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,569 bytes
コンパイル時間 950 ms
コンパイル使用メモリ 108,544 KB
実行使用メモリ 18,816 KB
最終ジャッジ日時 2024-11-17 07:33:46
合計ジャッジ時間 2,743 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int inputCount = int.Parse(Reader.ReadLine());
        
        Dictionary<string, int> dic = new Dictionary<string, int>();
        for(int i=0; i<inputCount; i++) {
            string eto = Reader.ReadLine();
            if(dic.ContainsKey(eto)) {
                dic[eto]++;
            } else
            {
                dic.Add(eto,1);
            }
        }
        
        bool ans = true;
        if(inputCount % 2 == 1 && dic.Max(a=>a.Value) > (inputCount / 2 + 1)) {
            ans = false;
        } else if(inputCount % 2 ==0 && dic.Max(a=>a.Value) > inputCount / 2) {
            ans = false;
        }
        Console.WriteLine(ans?"YES":"NO");

    }
    


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"



12
ne
ushi
tora
u
tatsu
mi
uma
hitsuji
saru
tori
inu
i




";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0