import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { static boolean debug = false; static boolean batch = false; static boolean readFile = false; static int num = 0; static int N, K; static int[] t, u; static double D; public static void main(String[] args) throws Exception { if (batch) { readFile = true; } if (readFile) { if (batch) { long tl = 2000; // TODO long tw = (long) (tl * 0.9); long total = 0; int bidx = 0; long best = 0; int widx = 0; long worst = 1000000000000000000L; int re = 0; int tle = 0; for (int z = 0; z < 100; z++) { try { makeCase(); long st = System.currentTimeMillis(); long score = solve(); long time = System.currentTimeMillis() - st; if (time > tw) { System.out.println(z + ":\t" + score + "\t" + time + "ms"); if (time > tl) { tle++; } } else { System.out.println(z + ":\t" + score); } total += score; if (score > best) { best = score; bidx = z; } if (score < worst) { worst = score; widx = z; } } catch (Exception e) { System.out.println(z + ":\t" + e.getMessage()); re++; } } System.out.println("total: " + total); System.out.println("best: " + bidx + ": " + best); System.out.println("worst: " + widx + ": " + worst); System.out.println("RE: " + re); System.out.println("TLE: " + tle); } else { makeCase(); long score = solve(); System.out.println(score); } } else { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); init(br); solve(); } } static void makeCase() { } static void init(BufferedReader br) throws Exception { String[] sa = br.readLine().split(" "); N = Integer.parseInt(sa[0]); K = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); t = new int[K]; for (int i = 0; i < K; i++) { t[i] = Integer.parseInt(sa[i]); } sa = br.readLine().split(" "); u = new int[K]; for (int i = 0; i < K; i++) { u[i] = Integer.parseInt(sa[i]); } D = 20000000.0 / N / (N - 1); } static long solve() throws Exception { int[] b = new int[N]; int[] m = new int[N]; int[] e = new int[N]; for (int i = 0; i < N; i++) { m[i] = rand(4, 6); b[i] = rand(m[i], m[i] * 2); e[i] = rand(1, 4); } if (!debug) { for (int i = 0; i < N; i++) { System.out.println(b[i] + " " + m[i] + " " + e[i]); } } if (debug) { long score = score(b, m, e); System.out.println(score); return score; } return 0; } static long score(int[] b, int[] m, int[] e) { long sumt = 0; long sumu = 0; for (int i = 0; i < K; i++) { int[] x = new int[N]; for (int j = 0; j < N; j++) { x[j] = getX(b[j], m[j], e[j], t[i]); } int max = 0; double val = 0; for (int j = 0; j < N - 1; j++) { for (int j2 = j + 1; j2 < N; j2++) { val += (double) Math.abs(x[j] - x[j2]) / (b[j] + b[j2]); max = Math.max(max, Math.abs(x[j] - x[j2])); } } sumt += Math.round(val * D); double v1 = max / 20.0 + 1; double v2 = Math.sqrt(v1); sumu += Math.round(10000000 / v2); } long avet = Math.round((double) sumt / K); long aveu = Math.round((double) sumu / K); if (debug) { System.out.println(avet); System.out.println(aveu); } return avet * aveu; } static int getX(int b, int m, int e, int time) { if (time <= b) { return time; } int nx = b; int nt = b; int h = Math.max(b * 2 - e, m * 2); int d = -1; while (true) { if (time <= nt + h) { return nx + (time - nt) * d; } nx += h * d; nt += h; h = Math.max(h - e * 2, m * 2); d = -d; } } static int rand(int l, int r) { int d = r - l; int ret = (int) (Math.random() * d); return ret + l; } }