結果

問題 No.182 新規性の虜
ユーザー chankou0920
提出日時 2017-10-17 16:03:12
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 108,892 KB
実行使用メモリ 27,524 KB
最終ジャッジ日時 2024-11-17 21:57:54
合計ジャッジ時間 4,579 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Program {
	public static void Main(string[] args) {
		Console.ReadLine(); // n
		string[] s = Console.ReadLine().Split(' ');
		
		// int型配列に変換し、ソートする。
		int[] array = new int[s.Length];
		for (int i = 0; i < array.Length; i++) {
			array[i] = int.Parse(s[i]);
		}
		Array.Sort(array);
		
		int count = 0;
		for (int i = 1; i < array.Length - 1; i++) {
			// 前後が同じ値でなければ新規性がある。
			if (array[i] != array[i-1] && array[i] != array[i+1]) {
				count++;
				/*
				前から2番目(後ろから2番目)が新規性ならば、
				前から1番目(後ろから1番目)も新規性である。
				*/
				if (i == 1 || i == array.Length - 2) {
					count++;	
				}
			}
		}
		
		Console.WriteLine(count);
	}
}
0