結果

問題 No.21 平均の差
ユーザー kitamoto0407kitamoto0407
提出日時 2024-03-07 01:58:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 80 ms / 5,000 ms
コード長 1,325 bytes
コンパイル時間 5,703 ms
コンパイル使用メモリ 77,552 KB
実行使用メモリ 54,752 KB
最終ジャッジ日時 2024-03-07 01:58:58
合計ジャッジ時間 7,480 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
54,752 KB
testcase_01 AC 64 ms
54,632 KB
testcase_02 AC 65 ms
54,748 KB
testcase_03 AC 64 ms
54,740 KB
testcase_04 AC 64 ms
54,752 KB
testcase_05 AC 80 ms
54,624 KB
testcase_06 AC 65 ms
54,640 KB
testcase_07 AC 64 ms
54,744 KB
testcase_08 AC 64 ms
54,748 KB
testcase_09 AC 64 ms
54,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.stream.*;

// 処理
class Process {
    private PrintWriter printWriter;
    private int[] n;

    Process(PrintWriter printWriter, int[] n) {
        this.printWriter = printWriter;
        this.n = n;
    }

    // 結果を出力
    void printResult() throws IOException {
        printWriter.println(IntStream.of(n).max().getAsInt() - IntStream.of(n).min().getAsInt());
    }
}

public class Main {
    public static void main(String[] args) throws IOException {
        var bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        var printWriter    = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

        // 入力
        int N = Integer.parseInt(bufferedReader.readLine().trim());

        int K = Integer.parseInt(bufferedReader.readLine().trim());

        int[] n = new int[N];
        for(int i = 0; i < N; i++) {
            n[i] = Integer.parseInt(bufferedReader.readLine().trim());
        }

        // Process クラスで処理を行う
        var process = new Process(printWriter, n);
        process.printResult();

        // 各ストリームを閉じる
        // 出力ストリームを閉じるときに標準出力に文字を出力する
        bufferedReader.close();
        printWriter.close();
    }
}
0