結果

問題 No.135 とりあえず1次元の問題
ユーザー huffman56huffman56
提出日時 2022-07-09 18:54:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 793 bytes
コンパイル時間 2,771 ms
コンパイル使用メモリ 104,108 KB
実行使用メモリ 30,920 KB
最終ジャッジ日時 2023-08-30 02:56:42
合計ジャッジ時間 5,583 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
30,404 KB
testcase_01 AC 61 ms
23,684 KB
testcase_02 AC 61 ms
21,752 KB
testcase_03 AC 61 ms
23,824 KB
testcase_04 AC 61 ms
21,748 KB
testcase_05 AC 61 ms
21,884 KB
testcase_06 AC 61 ms
21,704 KB
testcase_07 AC 62 ms
21,836 KB
testcase_08 AC 61 ms
19,700 KB
testcase_09 AC 62 ms
23,684 KB
testcase_10 AC 61 ms
19,652 KB
testcase_11 AC 61 ms
21,636 KB
testcase_12 AC 70 ms
23,940 KB
testcase_13 AC 61 ms
23,736 KB
testcase_14 AC 70 ms
21,840 KB
testcase_15 AC 68 ms
21,924 KB
testcase_16 AC 69 ms
23,836 KB
testcase_17 AC 68 ms
21,956 KB
testcase_18 AC 67 ms
19,860 KB
testcase_19 AC 70 ms
21,952 KB
testcase_20 AC 69 ms
21,960 KB
testcase_21 AC 118 ms
30,920 KB
testcase_22 AC 126 ms
28,460 KB
evil01.txt AC 126 ms
30,424 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace SortItems
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(x);
            var ans = 1000001;

            for (var i = 0; i < n; i++)
            {
                if (i == n-1)
                {
                    break;
                }

                if (x[i] != x[i+1])
                {
                    ans = Math.Min(Math.Abs(x[i] - x[i + 1]), ans);
                }

            }
            if (ans == 1000001)
            {
                ans = 0;
            }

            Console.WriteLine(ans);
        }
    }
}
0