結果

問題 No.135 とりあえず1次元の問題
ユーザー chankou0920chankou0920
提出日時 2017-10-16 11:50:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 471 bytes
コンパイル時間 3,048 ms
コンパイル使用メモリ 104,340 KB
実行使用メモリ 31,616 KB
最終ジャッジ日時 2023-08-11 06:46:38
合計ジャッジ時間 6,331 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
27,400 KB
testcase_01 AC 59 ms
18,776 KB
testcase_02 AC 59 ms
23,000 KB
testcase_03 AC 59 ms
20,876 KB
testcase_04 AC 60 ms
20,804 KB
testcase_05 AC 60 ms
20,892 KB
testcase_06 AC 59 ms
20,768 KB
testcase_07 AC 60 ms
20,840 KB
testcase_08 AC 61 ms
22,816 KB
testcase_09 AC 60 ms
22,928 KB
testcase_10 AC 60 ms
22,772 KB
testcase_11 AC 59 ms
20,800 KB
testcase_12 AC 66 ms
21,012 KB
testcase_13 AC 62 ms
20,808 KB
testcase_14 AC 68 ms
21,040 KB
testcase_15 AC 66 ms
20,960 KB
testcase_16 AC 67 ms
22,900 KB
testcase_17 AC 68 ms
21,096 KB
testcase_18 AC 66 ms
21,008 KB
testcase_19 AC 67 ms
23,016 KB
testcase_20 AC 67 ms
20,920 KB
testcase_21 AC 110 ms
27,788 KB
testcase_22 AC 123 ms
31,616 KB
evil01.txt AC 120 ms
29,476 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[] x = new int[s.Length];
		for (int i = 0; i < x.Length; i++) {
			x[i] = int.Parse(s[i]);
		}
		Array.Sort(x);
		
		int min = 0;
		for (int i = 1; i < x.Length; i++) {
			int dist = Math.Abs(x[i] - x[i-1]);
			if (dist < min && dist != 0 || min == 0) {
				min = dist;
			}
		}
		Console.WriteLine(min);
	}
}
0