結果

問題 No.182 新規性の虜
ユーザー yuki2006yuki2006
提出日時 2018-01-15 14:50:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 1,426 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 102,236 KB
実行使用メモリ 29,748 KB
最終ジャッジ日時 2023-08-27 17:04:30
合計ジャッジ時間 6,022 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
22,744 KB
testcase_01 AC 59 ms
20,692 KB
testcase_02 AC 60 ms
20,708 KB
testcase_03 AC 60 ms
20,708 KB
testcase_04 AC 60 ms
22,656 KB
testcase_05 AC 62 ms
20,712 KB
testcase_06 AC 60 ms
20,640 KB
testcase_07 AC 60 ms
20,700 KB
testcase_08 AC 103 ms
27,524 KB
testcase_09 AC 125 ms
29,748 KB
testcase_10 AC 116 ms
26,972 KB
testcase_11 AC 107 ms
25,884 KB
testcase_12 AC 84 ms
22,404 KB
testcase_13 AC 60 ms
20,808 KB
testcase_14 AC 61 ms
20,848 KB
testcase_15 AC 57 ms
20,784 KB
testcase_16 AC 59 ms
20,724 KB
testcase_17 AC 60 ms
18,520 KB
testcase_18 AC 107 ms
25,780 KB
testcase_19 AC 95 ms
22,408 KB
testcase_20 AC 84 ms
23,784 KB
testcase_21 AC 112 ms
26,012 KB
testcase_22 AC 88 ms
24,572 KB
testcase_23 AC 58 ms
22,776 KB
testcase_24 AC 111 ms
28,888 KB
testcase_25 AC 104 ms
25,276 KB
testcase_26 AC 75 ms
21,540 KB
testcase_27 AC 60 ms
22,756 KB
evil01.txt AC 120 ms
28,616 KB
evil02.txt AC 120 ms
28,460 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;

namespace lecture
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string row = Console.ReadLine();
            int N = int.Parse(row);

            row = Console.ReadLine();
            // 空白区切りで一旦文字列の配列に区切る
            string[] tmp = row.Split();

            // 文字列の配列に区切ったあとに1つずつそれぞれ数値の配列に変換する
            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(tmp[i]);
            }
            Array.Sort(A);

            int ans = 0;
            for (int i = 1; i < N - 1; i++)
            {
                if (!(A[i] == A[i - 1] || A[i] == A[i + 1]))
                {
                    ans++;
                }
            }
            if (N == 1)
            {
                ans = 1;
            }
            else if (N > 1)
            {
                // 左端でみたときにとなりが違っていたら
                if (A[0] != A[1])
                {
                    ans++;
                }
                // 右端でみたときにとなりが違っていたら
                if (A[N - 1] != A[N - 2])
                {
                    ans++;
                }
            }


            Console.WriteLine(ans);
        }

    }
}
0