結果

問題 No.182 新規性の虜
ユーザー yuki2006yuki2006
提出日時 2018-01-15 14:44:22
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,252 bytes
コンパイル時間 2,403 ms
コンパイル使用メモリ 104,856 KB
実行使用メモリ 29,736 KB
最終ジャッジ日時 2023-08-25 17:13:44
合計ジャッジ時間 7,063 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 RE -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
evil01.txt WA -
evil02.txt WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 (A[0] != A[1])
            {
                ans++;
            }
            // 右端でみたときにとなりが違っていたら
            if (A[N - 1] == A[N - 2])
            {
                ans++;
            }

            Console.WriteLine(ans);
        }

    }
}
0