結果

問題 No.135 とりあえず1次元の問題
ユーザー TDTD
提出日時 2022-06-02 10:04:15
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 1,116 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 107,108 KB
実行使用メモリ 26,780 KB
最終ジャッジ日時 2023-10-21 01:06:19
合計ジャッジ時間 2,738 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
26,188 KB
testcase_01 AC 27 ms
18,156 KB
testcase_02 AC 27 ms
18,156 KB
testcase_03 AC 26 ms
18,156 KB
testcase_04 AC 27 ms
18,160 KB
testcase_05 AC 28 ms
18,160 KB
testcase_06 AC 27 ms
18,160 KB
testcase_07 AC 27 ms
18,160 KB
testcase_08 AC 27 ms
18,160 KB
testcase_09 AC 27 ms
18,160 KB
testcase_10 AC 27 ms
18,160 KB
testcase_11 AC 27 ms
18,160 KB
testcase_12 AC 32 ms
18,536 KB
testcase_13 AC 27 ms
18,160 KB
testcase_14 AC 32 ms
18,572 KB
testcase_15 AC 31 ms
18,540 KB
testcase_16 AC 32 ms
18,576 KB
testcase_17 AC 31 ms
18,572 KB
testcase_18 AC 31 ms
18,524 KB
testcase_19 AC 31 ms
18,568 KB
testcase_20 AC 32 ms
18,568 KB
testcase_21 AC 75 ms
26,780 KB
testcase_22 AC 84 ms
26,276 KB
evil01.txt AC 82 ms
26,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int[] b = new int[a];
            int ans = 1;
            int c = 0;

            for (int x = 0; x < a ; x++)
            {
                b[x] = int.Parse(s[x]);
            }

            Array.Sort(b);

            for(int z = 0; z < a-1; z++)
            {

                if (z == 0)
                {
                    ans = b[z + 1] - b[z];
                }
                else if(b[z-1]==b[z])
                {
                    if (ans > b[z - 1])
                    {
                        ans = b[z + 1];
                    }else if (ans == 0)
                    {
                        ans = b[z + 1];
                    }
                }
                else if (ans> b[z + 1] - b[z]&& b[z + 1] - b[z]!=0)
                {
                    ans = b[z + 1] - b[z];
                }
            }
            Console.WriteLine(ans);
        }
    }
}
0