結果

問題 No.182 新規性の虜
ユーザー chankou0920chankou0920
提出日時 2017-10-17 16:25:26
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 811 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 100,880 KB
実行使用メモリ 28,108 KB
最終ジャッジ日時 2023-08-27 16:41:41
合計ジャッジ時間 5,537 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
22,896 KB
testcase_01 AC 54 ms
18,636 KB
testcase_02 AC 53 ms
20,684 KB
testcase_03 AC 54 ms
22,860 KB
testcase_04 AC 52 ms
22,792 KB
testcase_05 AC 55 ms
20,752 KB
testcase_06 AC 51 ms
20,736 KB
testcase_07 AC 52 ms
20,812 KB
testcase_08 AC 85 ms
25,696 KB
testcase_09 AC 106 ms
27,796 KB
testcase_10 AC 99 ms
27,264 KB
testcase_11 AC 94 ms
28,108 KB
testcase_12 AC 76 ms
22,592 KB
testcase_13 AC 55 ms
20,848 KB
testcase_14 AC 55 ms
20,840 KB
testcase_15 AC 52 ms
22,848 KB
testcase_16 AC 53 ms
20,932 KB
testcase_17 AC 52 ms
20,692 KB
testcase_18 AC 95 ms
27,868 KB
testcase_19 AC 92 ms
22,572 KB
testcase_20 AC 83 ms
21,792 KB
testcase_21 AC 111 ms
26,216 KB
testcase_22 AC 89 ms
22,824 KB
testcase_23 AC 57 ms
20,904 KB
testcase_24 AC 101 ms
27,052 KB
testcase_25 AC 94 ms
25,488 KB
testcase_26 AC 65 ms
23,672 KB
testcase_27 AC 53 ms
20,692 KB
evil01.txt AC 100 ms
28,672 KB
evil02.txt AC 103 ms
28,604 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 = 0; i < array.Length; i++) {
			if (array.Length == 1) {
				count = 1;
				break;
			}
			// 前後が同じ値でなければ新規性がある。
			if (i == 0) {
				if (array[i] != array[i+1]) {
					count++;
				}
			} else if (i == array.Length - 1) {
				if (array[i] != array[i-1]) {
					count++;
				}
			} else if (array[i] != array[i-1] && array[i] != array[i+1]) {
				count++;
			}
		}
		
		Console.WriteLine(count);
	}
}
0