結果

問題 No.135 とりあえず1次元の問題
ユーザー TDTD
提出日時 2022-06-02 09:45:42
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,403 bytes
コンパイル時間 1,569 ms
コンパイル使用メモリ 107,668 KB
実行使用メモリ 38,724 KB
最終ジャッジ日時 2023-10-21 01:06:10
合計ジャッジ時間 14,455 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
evil01.txt -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
            }
            for (int i = 0; i < a; i++)
            {
                
                for (int j = i; j < a; j++)
                {
                    
                    if (b[i] > b[j])
                    {
                        c = b[i];
                        b[i] = b[j];
                        b[j] = c;
                        
                    }
                    
                }
            }
            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