CF 1131C Birthday

博客内容讲述了在Cowboy Vlad的生日聚会上,孩子们想要围成一个圈并使相邻孩子之间的身高差最小。问题转化为求解最小不适感,即相邻孩子身高差的最大值。解决方案是先对孩子的身高进行排序,然后将最高者放在中间,其余孩子按身高递增顺序交替放置,以达到最小不适感。
摘要由CSDN通过智能技术生成

C. Birthday
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Cowboy Vlad has a birthday today! There are n children who came to the celebration. In order to greet Vlad, the children decided to form a circle around him. Among the children who came, there are both tall and low, so if they stand in a circle arbitrarily, it may turn out, that there is a tall and low child standing next to each other, and it will be difficult for them to hold hands. Therefore, children want to stand in a circle so that the maximum difference between the growth of two neighboring children would be minimal possible.

Formally, let’s number children from 1 to n in a circle order, that is, for every i child with number i will stand next to the child with number i+1, also the child with number 1 stands next to the child with number n. Then we will call the discomfort of the circle the maximum absolute difference o

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值