結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー yuki2006
提出日時 2019-06-22 15:39:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 1,289 bytes
コンパイル時間 2,700 ms
コンパイル使用メモリ 105,088 KB
実行使用メモリ 23,936 KB
最終ジャッジ日時 2024-12-26 09:14:07
合計ジャッジ時間 4,316 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 Algorithm
{
    class Program
    {
        static void Logic(List<int> list)
        {
            list.Sort();

            int count = 0;
            int preNumber = 0;
            int countMax = 0;
            int answer = 0;

            for(int i = 0; i < list.Count; i++)
            {
                if (preNumber == list[i])
                {
                    // 前回の数字と同じ場合
                    count++;

                }
                else
                {
                    // 前回の数字と違う場合
                    count = 1;
                    preNumber = list[i];
                }

                if (count >= countMax)
                {
                    // 最大値が同じか超えた場合 その時の更新する
                    countMax = count;
                    answer = list[i];
                }


            }
       

            Console.WriteLine(answer);
        }


        static void Main(string[] args)
        {
            Console.ReadLine(); // N
            var list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            Logic(list);
        }
    }
}
0