結果

問題 No.182 新規性の虜
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2015-04-13 06:06:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 112 ms / 5,000 ms
コード長 1,568 bytes
コンパイル時間 5,463 ms
コンパイル使用メモリ 109,404 KB
実行使用メモリ 33,156 KB
最終ジャッジ日時 2023-08-27 07:01:30
合計ジャッジ時間 6,450 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
21,412 KB
testcase_01 AC 63 ms
23,548 KB
testcase_02 AC 63 ms
21,424 KB
testcase_03 AC 64 ms
23,448 KB
testcase_04 AC 63 ms
21,408 KB
testcase_05 AC 63 ms
19,488 KB
testcase_06 AC 64 ms
21,396 KB
testcase_07 AC 63 ms
21,380 KB
testcase_08 AC 96 ms
28,812 KB
testcase_09 AC 112 ms
33,156 KB
testcase_10 AC 104 ms
30,708 KB
testcase_11 AC 100 ms
31,236 KB
testcase_12 AC 82 ms
23,940 KB
testcase_13 AC 62 ms
21,440 KB
testcase_14 AC 64 ms
21,572 KB
testcase_15 AC 61 ms
21,396 KB
testcase_16 AC 62 ms
19,368 KB
testcase_17 AC 64 ms
23,524 KB
testcase_18 AC 97 ms
27,056 KB
testcase_19 AC 89 ms
23,896 KB
testcase_20 AC 81 ms
23,024 KB
testcase_21 AC 100 ms
27,340 KB
testcase_22 AC 85 ms
25,532 KB
testcase_23 AC 61 ms
21,476 KB
testcase_24 AC 110 ms
32,788 KB
testcase_25 AC 97 ms
26,200 KB
testcase_26 AC 76 ms
22,592 KB
testcase_27 AC 62 ms
21,384 KB
evil01.txt AC 117 ms
36,492 KB
evil02.txt AC 115 ms
34,252 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.Collections.Generic;
using System.Linq;

static public class Program
{
    static public void Main()
    {
        var n = readInteger().Validate(x => 1 <= x && x <= (int)1e5);
        var a = readInteger(n).ValidateArray(x => 1 <= x && x <= (int)1e9);
        var dic = new Dictionary<int, int>();
        foreach (var x in a)
        {
            if (dic.ContainsKey(x))
                dic[x]++;
            else dic[x] = 1;
        }
        var cnt = dic.Count(x => x.Value == 1);
        Console.WriteLine(cnt);
    }

    static int readInteger()
    {
        var s = Console.ReadLine();
        return int.Parse(s);
    }
    static int[] readInteger(int n)
    {
        var s = Console.ReadLine().Split(' ');
        if (s.Length != n)
            throw new Exception(string.Format("invalid input, expected{0} actual{1}", n, s.Length));
        var ret = new int[n];
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(s[i]);
        return ret;
    }
    static void readEOF()
    {
        if (Console.In.Peek() >= 0)
            throw new Exception("invalid input too long input file");
    }

}
static public class Ex
{
    static public T Validate<T>(this T input, Func<T, bool> f)
    {
        if (!f(input))
            throw new Exception("invalid input");
        return input;
    }
    static public T[] ValidateArray<T>(this T[] input, Func<T, bool> f)
    {
        foreach (var x in input)
            if (!f(x))
                throw new Exception("invalid input");
        return input;
    }
}


0