結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー はまやんはまやん
提出日時 2019-06-22 15:22:16
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 69 ms / 5,000 ms
コード長 1,023 bytes
コンパイル時間 930 ms
コンパイル使用メモリ 113,128 KB
実行使用メモリ 25,856 KB
最終ジャッジ日時 2024-12-26 09:04:00
合計ジャッジ時間 2,998 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Threading.Tasks;

namespace proconCSharp
{
    class Program
    {
        static int GetInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] GetInts()
        {
            return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }

        static void Main()
        {
            var N = GetInt();
            var L = GetInts();

            var group = L.GroupBy(x => x);
            

            int ma = 0, ans = 0;
            foreach (var g in group)
            {
                if (ma < g.Count())
                {
                    ma = g.Count();
                    ans = g.ElementAt(0);
                }
                else if (ma == g.Count() && ans < g.ElementAt(0))
                {
                    ans = g.ElementAt(0);
                }
            }
            
            Console.WriteLine($"{ans}");
        }
    }
}
0