結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー nanophoto12
提出日時 2014-11-28 00:01:19
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 65 ms / 5,000 ms
コード長 1,031 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 112,824 KB
実行使用メモリ 31,836 KB
最終ジャッジ日時 2024-06-26 07:14:44
合計ジャッジ時間 2,990 ms
ジャッジサーバーID
(参考情報)
judge4 / 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;

class Probram79
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var dictionary = new Dictionary<int, int>();
        for (int i = 0; i < n; i++)
        {
            int level = array[i];
            if (dictionary.ContainsKey(level))
            {
                dictionary[level]++;
            }
            else
            {
                dictionary.Add(level,1);
            }
        }
        var keys = dictionary.Keys.ToArray();
        var values = dictionary.Values.ToArray();
        var max = values.Max();
        int maxValue = int.MinValue;
        for (int i = 0; i < keys.Length; i++)
        {
            if (values[i] == max)
            {
                maxValue = Math.Max(maxValue, keys[i]);
            }
        }
        Console.WriteLine(maxValue);
    }
}
0