[Codeforces #608 div2]1271C Shawarma Tent

这是一道关于在城市地图上寻找最佳地点设立 Shawarma 帐篷以吸引最多学生的题目。题目描述了首都伯兰德的地图由平行于坐标轴的街道连接各个建筑物,并给出了学校和学生住处的位置。学生从学校到家会走最短路径,如果路径经过帐篷,学生就会买 Shawarma。目标是找到使购买 Shawarma 的学生数量最多的帐篷位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Description

The map of the capital of Berland can be viewed on the infinite coordinate plane. Each point with integer coordinates contains a building, and there are streets connecting every building to four neighbouring buildings. All streets are parallel to the coordinate axes.

The main school of the capital is located in (sx,sy)(sx,sy)(sx,sy). There are n students attending this school, the i-th of them lives in the house located in (xi,yi). It is possible that some students live in the same house, but no student lives in (sx,sy)(sx,sy)(sx,sy).

After classes end, each student walks from the school to his house along one of the shortest paths. So the distance the iii-th student goes from the school to his house is ∣sx−xi∣+∣sy−yi∣|s_x−x_i|+|s_y−y_i|sxxi+syyi.

The Provision Department of Berland has decided to open a shawarma tent somewhere in the capital (at some point with integer coordinates). It is considered that the iii-th student will buy a shawarma if at least one of the shortest paths from the school to the iii
-th student’s house goes through the point where the shawarma tent is located. It is forbidden to place the shawarma tent at the point where the school is located, but the coordinates of the shawarma tent may coincide with the coordinates of the house of some student (or even multiple students).

You want to find the maximum possible number of students buying shawarma and the optimal location for the tent itself.

Input

The first line contains three integers nnn, sxsx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值