Skip to main content

Posts

Adding Squares Codechef October Long challenge Problem Code

 Adding Squares  Codechef October Long challenge Problem Code- problem Statement- There are  N N  different vertical lines on the plane,  i i -th of which is defined by the equation  x = a i x = a i  ( 0 ≤ a i ≤ W 0 ≤ a i ≤ W ) and  M M  different horizontal lines,  i i -th of which is defined by the equation  y = b i y = b i  ( 0 ≤ b i ≤ H 0 ≤ b i ≤ H ). You must add one line of the form  y = k y = k  ( 0 ≤ k ≤ H 0 ≤ k ≤ H ,  k ≠ b i k ≠ b i  for every  1 ≤ i ≤ M 1 ≤ i ≤ M ) to the plane. What is the maximum possible number of squares with different areas you can obtain on the plane? (Squares can have other lines passing through them) Input: First line will contain  4 4  integers  W W ,  H H ,  N N ,  M M Second line will contain  N N  different integers  a 1 , a 2 , . . . , a N a 1 , a 2 , . . . , a N Third line will contain  M M  different integers  b 1 , b 2 , . . . , b M b 1 , b 2 , . . . , b M Output: Output the maximal possible number of squares with different area on the plane