bzoj1650
题解:
二分答案
然后贪心
代码:
#include<bits/stdc++.h>
using namespace std;
const int N=;
int n,m,l,a[N];
int pd(int x)
{
int last=,num=;
for (int i=;i<=n;i++)
if (a[i]-a[last]<x)num++;
else last=i;
return num<=m;
}
int main()
{
scanf("%d%d%d",&l,&n,&m);
a[]=;
for (int i=;i<=n+;i++)scanf("%d",&a[i]);
a[n+]=l;
n+=;
sort(a+,a+n+);
int l=,r=1e9;
while (l<r)
{
int mid=(l+r+)/;
if (pd(mid))l=mid;
else r=mid-;
}
printf("%d",l);
}
bzoj1650的更多相关文章
- bzoj1650 [Usaco2006 Dec]River Hopscotch 跳石子
Description Every year the cows hold an event featuring a peculiar version of hopscotch that involve ...
- bzoj1650 / P2855 [USACO06DEC]河跳房子River Hopscotch / P2678 (noip2015)跳石头
P2855 [USACO06DEC]河跳房子River Hopscotch 二分+贪心 每次二分最小长度,蓝后检查需要去掉的石子数是否超过限制. #include<iostream> #i ...
- 【刷水-二分答案】BZOJ1650 & BZOJ1639
BZOJ1650-[Usaco2006 Dec]River Hopscotch 跳石子 [题目大意] 数轴上有n个石子,第i个石头的坐标为Di,现在要从0跳到L,每次条都从一个石子跳到相邻的下一个石子 ...
- usaco silver刷水~其实是回顾一下,补题解
[BZOJ1606][Usaco2008 Dec]Hay For Sale 裸01背包 ;i<=n;i++) for(int j=m;j>=a[i];j--) f[j]=max(f[j], ...
- 8.3-8.7 usaco
summary:38 vijos1002:青蛙跳河. dp+压缩.距离大于100可以直接%100.然后数据范围小了很多可以dp了. #include<cstdio> #include< ...
- BZOJ第7页养成计划
嗯,用这篇博客当一个目录,方便自己和学弟(妹?)们查阅.不定期更新. BZOJ1600 BZOJ1601 BZOJ1602 BZOJ1603 BZOJ1604 BZOJ1605 ...
- [转载]hzwer的bzoj题单
counter: 664BZOJ1601 BZOJ1003 BZOJ1002 BZOJ1192 BZOJ1303 BZOJ1270 BZOJ3039 BZOJ1191 BZOJ1059 BZOJ120 ...
- BZOJ刷题列表【转载于hzwer】
沿着黄学长的步伐~~ 红色为已刷,黑色为未刷,看我多久能搞完吧... Update on 7.26 :之前咕了好久...(足见博主的flag是多么emmm......)这几天开始会抽时间刷的,每天几道 ...
随机推荐
- C++ 细小知识点
1. C++ 拷贝构造函数参数为const类型 原因:因为复制构造函数是用引用方式传递复制对象,引用方式传递的是地址,因此在构造函数内对该引用的修改会影响源对象,防止源对象被修改,就要把参数类型设为c ...
- Linux驱动模块的Makefile分析【转】
本文转载自:http://blog.chinaunix.net/uid-29307109-id-3993784.html 1. 获取内核版本 当设备驱动需要同时支持不同版本内核时,在编译阶段,内核模块 ...
- [BZOJ4391][Usaco2015 dec]High Card Low Card dp+set+贪心
Description Bessie the cow is a huge fan of card games, which is quite surprising, given her lack of ...
- Unity3D学习笔记(九):摄像机
3D数学复习 using System.Collections; using System.Collections.Generic; using UnityEngine; public class w ...
- CRLF line terminators导致shell脚本报错:command not found --转载
Linux和Windows文本文件的行结束标志不同.在Linux中,文本文件用"/n"表示回车换行,而Windows用"/r/n"表示回车换行.有时候在Wind ...
- 华中农业大学预赛 B Handing Out Candies 余数的和
Problem B: Handing Out Candies Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 258 Solved: 19[Submit ...
- rospy 中service
Server部分: #!/usr/bin/env python import sys import os import rospy #from beginner.srv import * from b ...
- html 画出矩形,鼠标弹起,矩形消失
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- [STL][C++]STACK QUEUE
参考:http://www.cnblogs.com/mfryf/archive/2012/08/09/2629992.html stackstack 模板类的定义在<stack>头文件中. ...
- 使用tk.mybatis快速开发curd
使用mybatis已经是可以快速开发程序了,对于单表的curd似乎是一种可抽象的结果,下面介绍tk.mybatis的使用方式. maven引用 我使用的是这个版本,所以相关功能介绍也是这个版本. 使用 ...