日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

POJ 3258 -- River Hopscotch(二分)

發布時間:2024/4/18 编程问答 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 POJ 3258 -- River Hopscotch(二分) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接

Description

Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a long, straight river with a rock at the start and another rock at the end, L units away from the start (1 ≤ L ≤ 1,000,000,000). Along the river between the starting and ending rocks, N (0 ≤ N ≤ 50,000) more rocks appear, each at an integral distance Di from the start (0 < Di < L).To play the game, each cow in turn starts at the starting rock and tries to reach the finish at the ending rock, jumping only from rock to rock. Of course, less agile cows never make it to the final rock, ending up instead in the river.Farmer John is proud of his cows and watches this event each year. But as time goes by, he tires of watching the timid cows of the other farmers limp across the short distances between rocks placed too closely together. He plans to remove several rocks in order to increase the shortest distance a cow will have to jump to reach the end. He knows he cannot remove the starting and ending rocks, but he calculates that he has enough resources to remove up to M rocks (0 ≤ M ≤ N).FJ wants to know exactly how much he can increase the shortest distance before he starts removing the rocks. Help Farmer John determine the greatest possible shortest distance a cow has to jump after removing the optimal set of M rocks.

Input

Line 1: Three space-separated integers: L, N, and M Lines 2..N+1: Each line contains a single integer indicating how far some rock is away from the starting rock. No two rocks share the same position.

Output

Line 1: A single integer that is the maximum of the shortest distance a cow has to jump after removing M rocks

Sample Input

25 5 2 2 14 11 21 17

Sample Output

4

AC

  • 二分枚舉答案,每次統計當前刪除石頭的個數,如果個數大于M證明mid偏大,如果個數小于M證明mid偏小,因為要求最大的長度,所以等于的時候和小于的情況相同(l = mid + 1)
#include <iostream> #include <stdio.h> #include <map> #include <vector> #include <algorithm> #define N 100005 #define ll long long using namespace std; int a[N]; int main() { #ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin); #endifint length, n, m;scanf("%d%d%d", &length, &n, &m);for (int i = 1; i <= n; ++i) {scanf("%d", &a[i]);}a[++n] = length; sort(a + 1, a + 1 + n);int l = 1, r = length;while (l <= r) {int mid = (l + r) >> 1;int sum = 0;for (int i = 0; i < n; ++i) {int len = 0;for (int j = i + 1; j <= n; ++j) {len = a[j] - a[i];if (len >= mid) {len = 0;sum += j - i - 1;i = j - 1;break;}}if (len > 0) {sum += n - i;break;}}if (sum > m) r = mid - 1;else l = mid + 1;}printf("%d\n", r);return 0; }

總結

以上是生活随笔為你收集整理的POJ 3258 -- River Hopscotch(二分)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产同性人妖ts口直男 | 亚洲乱码国产乱码精品 | 欧美日韩1 | 国产伦精品一区二区免费 | 国产成人精品亚洲男人的天堂 | 亚洲国产精品网站 | 色一情一乱一伦一区二区三区 | 波多野结衣导航 | h片在线免费 | 久久国产一 | 特级西西444www高清大胆免费看 | 今天高清视频在线观看视频 | 欧美视频一区二区三区在线观看 | 美梦视频大全在线观看高清 | 少妇超碰| 91色拍 | 五月激情丁香网 | 91视频国产免费 | 欧美人与动物xxxx | 91视频综合 | 徐锦江一级淫片免费看 | 精品国产伦一区二区三区免费 | av福利社| 日韩作爱视频 | www.com国产 | 精品国产一区二区三区在线观看 | 妞妞影视 | 黄色午夜影院 | 国产无精乱码一区二区三区 | 欧美亚洲第一区 | 成人片在线免费看 | 狠狠躁狠狠躁视频专区 | 天堂av网站 | 亚洲三页 | 性av网| 国产精品无码久久久久一区二区 | 美女张开腿让人桶 | 精品人妻少妇AV无码专区 | 国产欧美精品一区二区色综合 | 亚洲va天堂va欧美ⅴa在线 | 性av网| 91午夜精品亚洲一区二区三区 | 99精品欧美一区二区三区综合在线 | 91免费精品| 日韩激情图片 | 日韩爽爽视频 | 一区二区国产精品 | 熟女性饥渴一区二区三区 | 看了下面会湿的视频 | 免费黄色小视频在线观看 | 97在线精品 | 毛片亚洲av无码精品国产午夜 | 亚洲欧美日韩国产精品 | 人人澡人人澡 | 国产香蕉在线视频 | 亚洲女同av| 91久久国产| 日韩精品无码一区二区三区久久久 | 亚洲不卡中文字幕 | 性五月天 | 欧美激情视频一区 | 日韩av免费网站 | 欧美高清视频 | 69精品丰满人妻无码视频a片 | av在线h| 网址在线观看你懂的 | 娇妻之欲海泛舟无弹窗笔趣阁 | 久草热线| 肥熟女一区二区三肥熟女 | 国产理论| 另类视频在线观看+1080p | 极品久久久久久 | 91在线精品入口 | 亚洲黄色中文字幕 | av三级网 | 男人疯狂高潮呻吟视频 | 99re6这里只有精品 | 国产黄色大片在线观看 | 精品无码黑人又粗又大又长 | 亚洲午夜久久久久久久国产 | 欧美成在线观看 | www.国产精品视频 | 97在线观看视频免费 | 亚洲国产成人精品久久久 | 5a毛片 | 国产爱搞 | 97xxxxx | 欧美人禽杂交狂配 | 亚洲美女屁股眼交3 | 青娱乐福利视频 | 久久精工是国产品牌吗 | 在线观看高h | 精品黑人一区二区三区在线观看 | 亚洲精品二 | 欧美性插视频 | 在线免费观看视频 | 美女被c出水 | 亚洲天堂社区 | 久草三级|