結果

問題 No.135 とりあえず1次元の問題
ユーザー 🐧しゅんチャマ🌸🐧しゅんチャマ🌸
提出日時 2023-09-21 22:21:28
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,041 bytes
コンパイル時間 2,973 ms
コンパイル使用メモリ 72,872 KB
実行使用メモリ 60,888 KB
最終ジャッジ日時 2023-09-21 22:21:43
合計ジャッジ時間 10,148 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 596 ms
60,888 KB
testcase_01 AC 122 ms
55,504 KB
testcase_02 AC 123 ms
56,108 KB
testcase_03 WA -
testcase_04 AC 133 ms
55,828 KB
testcase_05 AC 135 ms
55,704 KB
testcase_06 AC 137 ms
55,668 KB
testcase_07 AC 139 ms
55,736 KB
testcase_08 AC 131 ms
56,064 KB
testcase_09 AC 132 ms
56,340 KB
testcase_10 AC 134 ms
55,516 KB
testcase_11 AC 138 ms
55,976 KB
testcase_12 AC 153 ms
55,676 KB
testcase_13 AC 135 ms
55,868 KB
testcase_14 AC 189 ms
56,192 KB
testcase_15 AC 152 ms
55,720 KB
testcase_16 AC 185 ms
56,220 KB
testcase_17 AC 183 ms
56,368 KB
testcase_18 AC 140 ms
55,808 KB
testcase_19 AC 186 ms
56,380 KB
testcase_20 AC 187 ms
55,880 KB
testcase_21 AC 572 ms
60,552 KB
testcase_22 AC 576 ms
60,676 KB
evil01.txt AC 616 ms
60,380 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]);
            }
        }
        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