Soal : [Versi Lama] Training Gate -> Struktur Data -> Soal Tambahan -> E. Rata-Rata
Case : Wrong answer, padahal sudah dipastikan benar, tidak ada spasi tambahan ataupun linebreak tambahan.
Code :
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int J = sc.nextInt();
ArrayList<Double> a = new ArrayList<Double>();
for(int i = 0; i < J;i++) {
a.add(sc.nextDouble());
}
DecimalFormat df = new DecimalFormat("#.00");
System.out.print(df.format(Collections.min(a)) + " " + df.format(Collections.max(a)) + " " + df.format(a.stream().mapToDouble(v->v).sum()/J));
sc.close();
}
}
Soal : [Versi Lama] Training Gate -> Struktur Data -> Soal Tambahan -> E. Rata-Rata Case : Wrong answer, padahal sudah dipastikan benar, tidak ada spasi tambahan ataupun linebreak tambahan.
Code :