結果

問題 No.135 とりあえず1次元の問題
ユーザー mban
提出日時 2016-11-07 10:31:27
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 104,320 KB
実行使用メモリ 27,392 KB
最終ジャッジ日時 2024-06-11 07:02:40
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
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;
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