CF1662I.Ice Cream Shop
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 pi 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 xi 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?
海滩上有一排 n 个棚屋,呈严格的直线排列:1 号棚屋位于最左侧,对每个 1≤i≤n−1,i+1 号棚屋位于 i 号棚屋右侧恰好 100 米处。在 i 号棚屋中住有 pi 人。
另有 m 位冰淇淋售卖者,其摊位也严格沿同一直线排列(与所有棚屋共线)。第 i 位冰淇淋售卖者的摊位位于第 1 号棚屋右侧 xi 米处。所有冰淇淋摊位的位置互不相同,但某个摊位的位置可能恰好与某座棚屋重合。
你现在打算新开一家冰淇淋店,并希望确定其最佳选址。你的店铺可建在海滩上的任意位置(不必距第 1 号棚屋为整数米),只要它与所有棚屋及其他冰淇淋摊位共线即可;即使该位置已有其他冰淇淋摊位或棚屋,你仍可在此处设店。已知:每位住在棚屋中的人仅当你的店铺到其所在棚屋的距离严格小于其到任意其他冰淇淋摊位的距离时,才会光顾你的店铺。
若每位住在棚屋中的人恰好购买一个冰淇淋,则当你最优选址时,最多能售出多少个冰淇淋?
输入格式
The first line contains two integers n and m (2≤n≤200000, 1≤m≤200000) — the number of huts and the number of ice cream sellers.
The second line contains n integers p1,p2,…,pn (1≤pi≤109) — the number of people in each hut.
The third line contains m integers x1,x2,…,xm (0≤xi≤109, xi=xj for i=j) — the location of each ice cream shop.
第一行包含两个整数 n 和 m(2≤n≤200000,1≤m≤200000)—— 分别表示小屋的数量和冰淇淋摊位的数量。
第二行包含 n 个整数 p1,p2,…,pn(1≤pi≤109)—— 表示每座小屋中的人数。
第三行包含 m 个整数 x1,x2,…,xm(0≤xi≤109,且当 i=j 时 xi=xj)—— 表示每个冰淇淋摊位的位置。
输出格式
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
输入#2
4 2 1 2 7 8 35 157
输出#2
15
输入#3
4 1 272203905 348354708 848256926 939404176 20
输出#3
2136015810
输入#4
3 2 1 1 1 300 99
输出#4
2
说明/提示
In the first sample, 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.

In the second sample, 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.

在第一个样例中,你可以将商店(如下图中橙色所示)放置在第一间小屋右侧 150 米处(例如),使其成为距离前两间小屋最近的商店;这两间小屋分别住有 2 人和 5 人,因此共售出 7 个冰淇淋。

在第二个样例中,你可以将商店放置在第一间小屋右侧 170 米处(例如),使其成为距离最后两间小屋最近的商店;这两间小屋分别住有 7 人和 8 人,因此共售出 15 个冰淇淋。

输入解题思路,AI测评打分。不知道怎么写?