結果

問題 No.135 とりあえず1次元の問題
ユーザー TDTD
提出日時 2022-06-02 10:01:38
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,014 bytes
コンパイル時間 953 ms
コンパイル使用メモリ 104,192 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-09-21 01:56:04
合計ジャッジ時間 2,784 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
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> b[z + 1] - b[z]&& b[z + 1] - b[z]!=0)
                {
                    ans = b[z + 1] - b[z];
                }
            }
            Console.WriteLine(ans);
        }
    }
}
0