【打CF,学算法——三星级】CodeForces 645C Enduring Exodus (二分+贪心)

博客介绍了如何解决CodeForces的一道算法题,涉及到二分查找和贪心策略。农夫约翰在旅店预订房间,希望与最远的牛之间的距离最小。题目解析了如何通过二分查找确定连续空房间的起始位置,再用贪心策略找到中间位置,以达到最小距离。并提供了题意、思路及代码实现。
摘要由CSDN通过智能技术生成

【CF简介】

提交链接:CF 645C


题面:

C. Enduring Exodus
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel consists of n rooms located in a row, some of which are occupied.

Farmer John wants to book a set of k + 1 currently unoccupied rooms for him and his cows. He wants his cows to stay as safe as possible, so he wishes to minimi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值