結果

問題 No.135 とりあえず1次元の問題
ユーザー 🐧しゅんチャマ🌸🐧しゅんチャマ🌸
提出日時 2023-09-21 22:24:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 582 ms / 5,000 ms
コード長 1,099 bytes
コンパイル時間 2,741 ms
コンパイル使用メモリ 72,460 KB
実行使用メモリ 60,680 KB
最終ジャッジ日時 2023-09-21 22:24:46
合計ジャッジ時間 9,442 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 568 ms
60,680 KB
testcase_01 AC 120 ms
55,988 KB
testcase_02 AC 120 ms
56,032 KB
testcase_03 AC 146 ms
55,880 KB
testcase_04 AC 129 ms
57,960 KB
testcase_05 AC 128 ms
56,172 KB
testcase_06 AC 129 ms
55,944 KB
testcase_07 AC 131 ms
55,864 KB
testcase_08 AC 128 ms
55,912 KB
testcase_09 AC 128 ms
55,760 KB
testcase_10 AC 128 ms
55,952 KB
testcase_11 AC 155 ms
55,864 KB
testcase_12 AC 153 ms
55,948 KB
testcase_13 AC 128 ms
55,928 KB
testcase_14 AC 178 ms
56,208 KB
testcase_15 AC 147 ms
55,948 KB
testcase_16 AC 168 ms
56,092 KB
testcase_17 AC 174 ms
56,052 KB
testcase_18 AC 137 ms
55,816 KB
testcase_19 AC 183 ms
56,040 KB
testcase_20 AC 171 ms
56,356 KB
testcase_21 AC 509 ms
60,640 KB
testcase_22 AC 582 ms
60,596 KB
evil01.txt AC 560 ms
60,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Y135{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int ans=2000000000;
        if(n==1){
            ans=1;
        }
        int[] x=new int[n];
        for(int i=0;i<n;i++){
            x[i]=sc.nextInt();
        }
        Arrays.sort(x);
        for(int i=0;i<n-1;i++){
            if(x[i]!=x[i+1]){
                ans=Math.min(ans,x[i+1]-x[i]);
            }
        }
        if(ans==2000000000){
            ans=0;
        }
        System.out.println(ans);
    }
}
/*
class Y135{
    public static void main(String arg[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] x=new int[n];
        for(int i=0;i<n;i++){
            x[i]=sc.nextInt();
        }
        int min=2000000000;
        for(int i=0;i<n-1;i++){
            for(int j=i;j<n;j++){
                if(Math.abs(x[i]-x[j])!=0&&Math.abs(x[i]-x[j])<min){
                    min=Math.abs(x[i]-x[j]);
                }
            }
        }
        System.out.println(min);
    }
}
*/
0