RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 ICPC00124

D. Ice Cream Shop

설명

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 \le i \le 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 \le n \le 200\,000\), \(1 \le m \le 200\,000\)) — the number of huts and the number of ice cream sellers. The second line contains \(n\) integers \(p_{1}\), \(p_{2}\), . . . , \(p_{n}\) (\(1 \le p_{i} \le 10^{9}\)) — the number of people in each hut. The third line contains \(m\) integers \(x_{1}\), \(x_{2}\), . . . , \(x_{m}\) (\(0 \le x_{i} \le 10^{9}\), \(x_{i}\)̸ = \(x_{j}\) for \(i\)̸ = \(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
출력
7
예제 2
입력
4 2
1 2 7 8
35 157
출력
15
예제 3
입력
4 1
272203905 348354708 848256926 939404176
20
출력
2136015810
예제 4
입력
3 2
1 1 1
300 99
출력
2
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC SWERC 2021

평가 및 의견

D. Ice Cream Shop

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

D. Ice Cream Shop

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8