結果
問題 | No.349 干支の置き物 |
ユーザー | No |
提出日時 | 2017-05-24 22:08:32 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 834 bytes |
コンパイル時間 | 766 ms |
コンパイル使用メモリ | 112,928 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-09-19 18:38:02 |
合計ジャッジ時間 | 2,743 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.
ソースコード
using System; using System.Linq; using System.Collections.Generic; namespace Yuki { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); var d = new Dictionary<string, int>(); for (int i = 0; i < n; i++) { string s = Console.ReadLine(); if (d.ContainsKey(s)) d[s] += 1; else d.Add(s, 1); } var k = d.Values.Max(); if (n % 2 == 1 && k <= (n + 1) / 2) { Console.WriteLine("YES"); } else if (n % 2 == 0 && k <= n / 2) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } } } }