아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Ice Cream Shop

시간 제한2초메모리 제한2048 MB

요약
기존 아이스크림 가게들이 늘어선 직선 위에 새 가게 하나를 놓아, 자기 집에서 가장 가까운 가게가 새 가게가 되는 사람 수를 최대로 만든다.
난이도

보통10점 중 7점

유형
정렬, 누적 합, 구간
정답자
아직 제출이 없습니다

문제

On a beach there are nn huts in a perfect line, hut 11 being at the left and hut i+1i + 1 being 100100 meters to the right of hut ii, for all 1≤i≤n−11 ≤ i ≤ n - 1. In hut ii there are p_ip\_i people.

There are mm ice cream sellers, also aligned in a perfect line with all the huts. The ii-th ice cream seller has their shop x_ix\_i meters to the right of the first hut. All ice cream shops are at distinct locations, but they may be at the same location as a hut.

You want to open a new ice cream shop and you wonder what the best location for your shop is. You can place your ice cream shop anywhere on the beach (not necessarily at an integer distance from the first hut) as long as it is aligned with the huts and the other ice cream shops, even if there is already another ice cream shop or a hut at that location. You know that people would come to your shop only if it is strictly closer to their hut than any other ice cream shop.

If every person living in the huts wants to buy exactly one ice cream, what is the maximum number of ice creams that you can sell if you place the shop optimally?

입력

The first line contains two integers nn and mm (2≤n≤200,0002 ≤ n ≤ 200\\,000, 1≤m≤200,0001 ≤ m ≤ 200\\,000) — the number of huts and the number of ice cream sellers.

The second line contains nn integers p_1p\_1, p_2p\_2, …\dots, p_np\_n (1≤p_i≤1091 ≤ p\_i ≤ 10^9) — the number of people in each hut.

The third line contains mm integers x_1x\_1, x_2x\_2, …\dots, x_mx\_m (0≤x_i≤1090 ≤ x\_i ≤ 10^9, x_i≠x_jx\_i \ne x\_j for i≠ji \ne j) — the location of each ice cream shop.

출력

Print the maximum number of ice creams that can be sold by choosing optimally the location of the new shop.

예제4

  1. 예제 1

    입력
    3 1
    2 5 6
    169
    
    예상 출력
    7
    
  2. 예제 2

    입력
    4 2
    1 2 7 8
    35 157
    
    예상 출력
    15
    
  3. 예제 3

    입력
    4 1
    272203905 348354708 848256926 939404176
    20
    
    예상 출력
    2136015810
    
  4. 예제 4

    입력
    3 2
    1 1 1
    300 99
    
    예상 출력
    2