結果

問題 No.24 数当てゲーム
ユーザー matsuyou1001matsuyou1001
提出日時 2020-01-07 14:28:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 1,032 bytes
コンパイル時間 2,463 ms
コンパイル使用メモリ 110,056 KB
実行使用メモリ 24,092 KB
最終ジャッジ日時 2023-08-14 23:20:57
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
24,080 KB
testcase_01 AC 74 ms
21,948 KB
testcase_02 AC 75 ms
24,092 KB
testcase_03 AC 76 ms
22,032 KB
testcase_04 AC 74 ms
22,204 KB
testcase_05 AC 77 ms
21,980 KB
testcase_06 AC 75 ms
20,080 KB
testcase_07 AC 76 ms
21,872 KB
testcase_08 AC 76 ms
24,000 KB
testcase_09 AC 74 ms
22,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;

class Program {
    static void Main() {
        var N = int.Parse(Console.ReadLine());

        var scores = Enumerable.Repeat<int?>(0, 10).ToArray();
        for (var turn = 1; turn <= N; turn++) {
            var inputs = Console.ReadLine().Split(' ');
            var nums = inputs.Take(4).Select(n => int.Parse(n)).ToArray();

            if (inputs.Last() == "YES") {
                foreach (var num in nums.Where(n => scores[n] is int))
                    scores[num]++;
            }
            else {
                foreach (var num in nums.Where(n => scores[n] is int))
                    scores[num] = null;
            }
        }

        var answer = scores.Select((score, num) => (score, num))
                           .Where(t => t.score is int)
                           .OrderByDescending(t => t.score)
                           .Select(t => t.num)
                           .First();

        Console.WriteLine(answer);

#if DEBUG
        Console.Read();
#endif
    }
}
0