Advertisement
ogv

Untitled

ogv
Jan 10th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4.     private static double solve(int N, int[] a) {
  5.         return 0;
  6.     }
  7.  
  8.     public static double run(Scanner scanner) {
  9.         int N = scanner.nextInt();
  10.         int[] a = new int[N];
  11.         for (int i=0; i < N; i++) a[i] = scanner.nextInt();
  12.  
  13.         return solve(N, a);
  14.     }
  15.  
  16.     public static void main(String[] args) {
  17.         try (Scanner scanner = new Scanner(System.in)) {
  18.             System.out.println(run(scanner));
  19.         }
  20.         Tests.run();
  21.     }
  22. }
  23.  
  24. class Tests {
  25.     public static void run() {
  26.         testCase("3\n" +
  27.                 "1 1 1", 5.5);
  28.         testCase("1\n" +
  29.                 "3", 3);
  30.         testCase("2\n" +
  31.                 "1 2", 4.5);
  32.         testCase("10\n" +
  33.                 "1 3 2 3 3 2 3 2 1 3", 54.48064457488221);
  34.  
  35.         System.out.println("DONE");
  36.     }
  37.  
  38.     private static void testCase(String input, double expected) {
  39.         try (Scanner scanner = new Scanner(input)) {
  40.             double result = Main.run(scanner);
  41.             if (Math.abs(result-expected) > 1e-9) System.out.println("TEST FAILED: was " + result + " expected " + expected + " on input\n" + input);
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement