NOIP2015提高组day2 —— 跳石头(stone)
来源:互联网 发布:杭州it培训机构 编辑:程序博客网 时间:2024/06/05 14:15
#include <fstream>using namespace std;ifstream fin("stone.in");ofstream fout("stone.out");int L, N, M, a[100000];bool OK(int len){ int lpoint=0, move_num=0; for (int i=0; i<=N; i++) if (a[i] - lpoint < len) move_num++; else lpoint=a[i]; return move_num <= M;}int main(){ fin>>L>>N>>M; for (int i=0; i<N; i++) fin>>a[i]; a[N]=L; int lowerlim=0, upperlim=L+1, middle; while (lowerlim+1 < upperlim) { middle = (lowerlim+upperlim)>>1; if (OK(middle)) lowerlim=middle; else upperlim=middle; } fout<<lowerlim<<endl; return 0;}
如果作死用穷举,只能过小数据,因为时间复杂度是
0 0
- NOIP2015提高组day2 —— 跳石头(stone)
- 跳石头 NOIP2015 提高组 Day2 T1
- C++——NOIP2015提高组day2 t1——跳石头
- {题解}[jzoj4326]NOIP2015提高组Day2 跳石头
- NOIP 2015 提高组 复赛 day2 stone 跳石头
- NOIP2015复赛提高组day2(A:跳石头 B:子串 C:运输计划)
- 【NOIP2015提高组】跳石头
- NOIP2015提高组 跳石头
- 【noip2015】【Day2】【跳石头】【字串】
- [NOIP2015] day2 T1 跳石头
- NOIP2015 Day2 T1 跳石头
- Vijos1981[Noip2015提高组]跳石头
- Noip2015 Day2 T1 跳石头(二分答案)
- Codevs 4768 跳石头 NOIP2015 DAY2 T1
- C++——NOIP2015提高组day2 t2——子串
- C++——NOIP2015提高组day2 t3——运输计划
- NOIP2015提高组Day2 子串
- {题解}[jzoj4328]NOIP2015提高组Day2 运输计划
- linux 信号发送函数sigqueue和信号安装函数sigaction用法
- 第一次自己比较的独立编写一个程序
- UVa 1400(LA 3938)动态最大连续和
- 2015年12月4日工作总结
- VIJOS-P1033
- NOIP2015提高组day2 —— 跳石头(stone)
- 计蒜客—爱奇异的自制节目
- 又鼓捣起刚毕业时玩的东西了
- [并发并行]_[初级]_[C++实现sychronized方式的对象锁]
- Install SVN Error:The Feature You Are Tring to Use is on a Network Resource That is Unvaliable
- 贪心——POJ1328
- Android 控件之DatePicker(日期和日历)
- linux 信号安装、signal、kill,arise讲解
- openfire的安装和配置