結果

問題 No.135 とりあえず1次元の問題
ユーザー bayashiko_rbayashiko_r
提出日時 2018-11-08 00:33:24
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 2,146 ms
コンパイル使用メモリ 102,556 KB
実行使用メモリ 29,392 KB
最終ジャッジ日時 2023-08-13 04:11:57
合計ジャッジ時間 5,542 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
27,424 KB
testcase_01 AC 57 ms
20,788 KB
testcase_02 AC 58 ms
20,848 KB
testcase_03 AC 58 ms
20,580 KB
testcase_04 AC 60 ms
22,776 KB
testcase_05 AC 60 ms
22,612 KB
testcase_06 AC 60 ms
20,876 KB
testcase_07 AC 60 ms
20,756 KB
testcase_08 AC 59 ms
20,652 KB
testcase_09 AC 59 ms
20,784 KB
testcase_10 AC 59 ms
22,808 KB
testcase_11 AC 58 ms
20,832 KB
testcase_12 AC 67 ms
20,996 KB
testcase_13 AC 58 ms
20,620 KB
testcase_14 AC 67 ms
20,920 KB
testcase_15 AC 66 ms
22,800 KB
testcase_16 AC 69 ms
20,700 KB
testcase_17 AC 66 ms
20,840 KB
testcase_18 AC 67 ms
20,848 KB
testcase_19 AC 66 ms
20,836 KB
testcase_20 AC 67 ms
20,924 KB
testcase_21 AC 109 ms
27,728 KB
testcase_22 AC 119 ms
29,392 KB
evil01.txt AC 117 ms
29,376 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