Basirovich Maxim

아직 제출이 없습니다시간 제한4초메모리 제한512 MB

문제

Note that 00-based indexing is used throughout the problem.

You are given an array aa of length nn and kk non-empty sets of integers from 00 to n1n-1. Let S_pS\_p denote the pp-th set. Each integer from 00 to n1n-1 belongs to exactly one of those sets. It is guaranteed that 00 belongs to S_0S\_0.

You choose a \uline{nonincreasing} array cc of nonnegative reals. c_0c\_0 must be positive. Let d_pd\_p denote _iS_pc_ia_i\sum\_{i \in S\_p} c\_i a\_i. Let XX denote min_p=1k1d_pd_0\frac{\min\_{p=1}^{k-1} d\_p}{d\_0}. What is the maximum value of XX you can obtain by choosing cc accordingly?

입력

The first line contains two integers nn and kk (2n4104,2k42 \leq n \leq 4 \cdot 10^4, 2 \leq k \leq 4), the length of aa and the number of sets. 

The second line contains nn integers a_ia\_i (1a_i1091 \leq a\_i \leq 10^9), the elements of aa.

The third line contains nn integers b_ib\_i (b_0=0,0b_i<kb\_0 = 0, 0 \leq b\_i < k) meaning that ii belongs to S_b_iS\_{b\_i}.

All sets S_pS\_p are non-empty. In other words, all integers from 00 to k1k-1 occur at least once among b_ib\_i.

출력

Print a single integer --- the maximum value of XX you can obtain accurate to absolute or relative error of at most 10410^{-4}.