結果

問題 No.135 とりあえず1次元の問題
ユーザー mbanmban
提出日時 2016-11-07 10:31:27
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 104,228 KB
実行使用メモリ 28,200 KB
最終ジャッジ日時 2023-09-02 00:37:43
合計ジャッジ時間 4,999 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
27,800 KB
testcase_01 AC 60 ms
23,028 KB
testcase_02 AC 59 ms
21,248 KB
testcase_03 AC 60 ms
21,092 KB
testcase_04 AC 61 ms
21,140 KB
testcase_05 AC 61 ms
21,092 KB
testcase_06 AC 61 ms
19,088 KB
testcase_07 AC 61 ms
21,060 KB
testcase_08 AC 61 ms
21,032 KB
testcase_09 AC 61 ms
21,120 KB
testcase_10 AC 61 ms
23,100 KB
testcase_11 AC 61 ms
19,196 KB
testcase_12 AC 69 ms
19,212 KB
testcase_13 AC 62 ms
21,044 KB
testcase_14 AC 69 ms
21,396 KB
testcase_15 AC 69 ms
21,368 KB
testcase_16 AC 70 ms
21,208 KB
testcase_17 AC 69 ms
19,196 KB
testcase_18 AC 68 ms
21,180 KB
testcase_19 AC 69 ms
23,312 KB
testcase_20 AC 68 ms
21,220 KB
testcase_21 AC 98 ms
28,200 KB
testcase_22 AC 102 ms
27,880 KB
evil01.txt AC 98 ms
27,832 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;

class Magatro
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        bool[] point = new bool[1000001];
        string[] s = Console.ReadLine().Split(' ');
        for(int i = 0; i < N; i++)
        {
            point[int.Parse(s[i])] = true;
        }
        int min = int.MaxValue;
        bool a=false;
        int sta = 0;
        bool k = false;
        for(int i = 0; i <= 1000000; i++)
        {
            if (!k)
            {
                if (point[i])
                {
                    sta = i;
                    k = true;
                }
            }
            else
            {
                if (point[i])
                {
                    min = Math.Min(min, i - sta);
                    a = true;
                    sta = i;
                }
            }
        }
        if (a)
        {
            Console.WriteLine(min);
        }
        else
        {
            Console.WriteLine(0);
        }
    }
}
0