Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- private static double solve(int N, int[] a) {
- return 0;
- }
- public static double run(Scanner scanner) {
- int N = scanner.nextInt();
- int[] a = new int[N];
- for (int i=0; i < N; i++) a[i] = scanner.nextInt();
- return solve(N, a);
- }
- public static void main(String[] args) {
- try (Scanner scanner = new Scanner(System.in)) {
- System.out.println(run(scanner));
- }
- Tests.run();
- }
- }
- class Tests {
- public static void run() {
- testCase("3\n" +
- "1 1 1", 5.5);
- testCase("1\n" +
- "3", 3);
- testCase("2\n" +
- "1 2", 4.5);
- testCase("10\n" +
- "1 3 2 3 3 2 3 2 1 3", 54.48064457488221);
- System.out.println("DONE");
- }
- private static void testCase(String input, double expected) {
- try (Scanner scanner = new Scanner(input)) {
- double result = Main.run(scanner);
- if (Math.abs(result-expected) > 1e-9) System.out.println("TEST FAILED: was " + result + " expected " + expected + " on input\n" + input);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement