結果

問題 No.182 新規性の虜
ユーザー yuki2006
提出日時 2018-01-15 14:20:44
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 1,221 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 110,516 KB
実行使用メモリ 25,984 KB
最終ジャッジ日時 2024-12-27 20:41:02
合計ジャッジ時間 3,373 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 = 0; i < N; i++)
            {
                if (i > 0 && A[i] == A[i - 1]){
                    // 左隣が同じだったら何もしない。
                }else if (i<N-1 && A[i] == A[i + 1]){                    
                    // 右隣が同じだったら何もしない。
                }else{
                    // どちらかの隣がA[i]と同じではなかったら
                    ans++;
                }

            }
            Console.WriteLine(ans);
        }

    }
}
0