結果

問題 No.135 とりあえず1次元の問題
ユーザー bayashiko_rbayashiko_r
提出日時 2018-11-08 00:33:24
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 89 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 963 ms
コンパイル使用メモリ 110,712 KB
実行使用メモリ 32,680 KB
最終ジャッジ日時 2024-04-30 22:34:21
合計ジャッジ時間 3,127 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
30,580 KB
testcase_01 AC 28 ms
26,068 KB
testcase_02 AC 29 ms
26,180 KB
testcase_03 AC 28 ms
24,160 KB
testcase_04 AC 28 ms
26,200 KB
testcase_05 AC 28 ms
24,296 KB
testcase_06 AC 28 ms
24,036 KB
testcase_07 AC 28 ms
21,936 KB
testcase_08 AC 28 ms
23,912 KB
testcase_09 AC 27 ms
22,328 KB
testcase_10 AC 29 ms
26,200 KB
testcase_11 AC 29 ms
24,156 KB
testcase_12 AC 33 ms
24,356 KB
testcase_13 AC 29 ms
25,948 KB
testcase_14 AC 33 ms
22,580 KB
testcase_15 AC 32 ms
24,416 KB
testcase_16 AC 33 ms
26,696 KB
testcase_17 AC 32 ms
24,676 KB
testcase_18 AC 32 ms
24,672 KB
testcase_19 AC 32 ms
26,556 KB
testcase_20 AC 33 ms
24,360 KB
testcase_21 AC 76 ms
31,160 KB
testcase_22 AC 87 ms
32,680 KB
evil01.txt AC 85 ms
30,488 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        string[] t = s.Split(' ');
        int[] X = new int[N];
        //数字の割り当て
        for (int i = 0; i < N; i++) {
            X[i] = int.Parse(t[i]);
        }

        //値をソートする
        Array.Sort(X);

        //隣との差の値
        int diff = X[N - 1];  //とりあえず最大値を与えておく

        //全ての数字について、差を求めていく(0の時は無視する)
        for (int i = 0; i < N - 1; i++) {
            if (X[i + 1] - X[i] != 0){
                diff = Math.Min(diff, X[i + 1] - X[i]);
            }
        }

        //出力
        Console.WriteLine(diff);
    }
}
0