Logo
(追記) (追記ここまで)

25056번 - Ice Cream Shop 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 2048 MB106545252.000%

문제

On a beach there are $n$ huts in a perfect line, hut 1ドル$ being at the left and hut $i + 1$ being 100ドル$ meters to the right of hut $i,ドル for all 1ドル ≤ i ≤ n - 1$. In hut $i$ there are $p_i$ people.

There are $m$ ice cream sellers, also aligned in a perfect line with all the huts. The $i$-th ice cream seller has their shop $x_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 $n$ and $m$ (2ドル ≤ n ≤ 200,000円,ドル 1ドル ≤ m ≤ 200,000円$) — the number of huts and the number of ice cream sellers.

The second line contains $n$ integers $p_1,ドル $p_2,ドル $\dots,ドル $p_n$ (1ドル ≤ p_i ≤ 10^9$) — the number of people in each hut.

The third line contains $m$ integers $x_1,ドル $x_2,ドル $\dots,ドル $x_m$ (0ドル ≤ x_i ≤ 10^9,ドル $x_i \ne x_j$ for $i \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.

제한

예제 입력 1

3 1
2 5 6
169

예제 출력 1

7

Explanation of sample 1.

You can place the shop (coloured orange in the picture below) 150ドル$ meters to the right of the first hut (for example) so that it is the closest shop to the first two huts, which have 2ドル$ and 5ドル$ people, for a total of 7ドル$ sold ice creams.

예제 입력 2

4 2
1 2 7 8
35 157

예제 출력 2

15

Explanation of sample 2.

You can place the shop 170ドル$ meters to the right of the first hut (for example) so that it is the closest shop to the last two huts, which have 7ドル$ and 8ドル$ people, for a total of 15ドル$ sold ice creams.

예제 입력 3

4 1
272203905 348354708 848256926 939404176
20

예제 출력 3

2136015810

예제 입력 4

3 2
1 1 1
300 99

예제 출력 4

2

힌트

출처

ICPC > Regionals > Europe > Southwestern European Regional Contest > SWERC 2021-2022 D번

  • 문제를 만든 사람: Stefanie Zbinden
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /