結果

問題 No.182 新規性の虜
ユーザー chankou0920chankou0920
提出日時 2017-10-17 16:03:12
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 107,888 KB
実行使用メモリ 32,772 KB
最終ジャッジ日時 2024-04-29 00:19:57
合計ジャッジ時間 3,246 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,172 KB
testcase_01 AC 27 ms
22,068 KB
testcase_02 AC 27 ms
24,032 KB
testcase_03 AC 27 ms
24,160 KB
testcase_04 AC 27 ms
24,108 KB
testcase_05 AC 28 ms
24,108 KB
testcase_06 AC 27 ms
24,040 KB
testcase_07 AC 27 ms
24,108 KB
testcase_08 AC 61 ms
28,964 KB
testcase_09 AC 82 ms
32,772 KB
testcase_10 AC 74 ms
30,360 KB
testcase_11 AC 67 ms
31,400 KB
testcase_12 AC 45 ms
27,876 KB
testcase_13 AC 27 ms
24,036 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 28 ms
26,204 KB
testcase_17 AC 27 ms
24,292 KB
testcase_18 AC 68 ms
29,148 KB
testcase_19 AC 57 ms
26,028 KB
testcase_20 WA -
testcase_21 AC 72 ms
31,392 KB
testcase_22 AC 50 ms
26,284 KB
testcase_23 WA -
testcase_24 AC 70 ms
30,192 KB
testcase_25 AC 67 ms
26,468 KB
testcase_26 AC 38 ms
27,232 KB
testcase_27 WA -
evil01.txt AC 76 ms
31,808 KB
evil02.txt AC 76 ms
31,904 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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