結果

問題 No.716 距離
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2019-02-19 17:41:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 787 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 76,556 KB
実行使用メモリ 50,708 KB
最終ジャッジ日時 2024-04-20 15:06:02
合計ジャッジ時間 9,986 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 185 ms
42,812 KB
testcase_01 AC 175 ms
42,780 KB
testcase_02 AC 187 ms
42,680 KB
testcase_03 AC 189 ms
42,576 KB
testcase_04 AC 178 ms
42,468 KB
testcase_05 AC 174 ms
42,812 KB
testcase_06 AC 178 ms
42,656 KB
testcase_07 AC 115 ms
40,136 KB
testcase_08 AC 115 ms
40,312 KB
testcase_09 AC 115 ms
40,056 KB
testcase_10 AC 176 ms
42,512 KB
testcase_11 AC 159 ms
41,960 KB
testcase_12 AC 184 ms
42,364 KB
testcase_13 AC 181 ms
42,584 KB
testcase_14 AC 117 ms
40,124 KB
testcase_15 AC 182 ms
50,708 KB
testcase_16 AC 172 ms
42,284 KB
testcase_17 AC 182 ms
42,436 KB
testcase_18 AC 140 ms
41,624 KB
testcase_19 AC 161 ms
42,280 KB
testcase_20 AC 116 ms
40,296 KB
testcase_21 AC 138 ms
41,308 KB
testcase_22 AC 162 ms
41,900 KB
testcase_23 AC 139 ms
41,672 KB
testcase_24 AC 183 ms
42,464 KB
testcase_25 AC 170 ms
42,324 KB
testcase_26 AC 173 ms
41,948 KB
testcase_27 AC 177 ms
42,396 KB
testcase_28 AC 138 ms
41,608 KB
testcase_29 AC 176 ms
42,312 KB
testcase_30 AC 176 ms
41,928 KB
testcase_31 AC 184 ms
42,016 KB
testcase_32 AC 178 ms
42,256 KB
testcase_33 AC 175 ms
42,056 KB
testcase_34 AC 177 ms
42,460 KB
testcase_35 AC 120 ms
40,264 KB
testcase_36 AC 142 ms
41,860 KB
testcase_37 AC 134 ms
41,612 KB
testcase_38 AC 172 ms
41,936 KB
testcase_39 AC 179 ms
42,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i=0; i<n; i++) {
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        printMin(list);
        printMax(list);
    }
    
    static void printMax(List<Integer> list) {
        int max = list.get(list.size()-1) - list.get(0);
        System.out.println(max);
    }
    
    static void printMin(List<Integer> list) {
        int min = list.get(list.size()-1) - list.get(0);
        for(int i=1; i<list.size(); i++) {
            min = Math.min(min, list.get(i) - list.get(i-1));
        }
        System.out.println(min);
    }
}
0