bzoj4582:简单递推题。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,s,t) for(int i=s;i<=t;i++)
int read(){
int x=0;char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) x=x*10+c-'0',c=getchar();
return x;
}
const int nmax=50005;
int a[nmax],rmax[nmax],res[nmax];
int main(){
int n=read(),k=read();
REP(i,1,n) a[i]=read();
sort(a+1,a+n+1);
REP(i,1,n){
int tmp=i;
while(a[tmp]-a[i]<=k&&tmp<=n) tmp++;
rmax[i]=tmp-i;
}
for(int i=n;i;i--) res[i]=max(res[i+1],rmax[i]);
int ans=-1;
REP(i,1,n) ans=max(ans,rmax[i]+res[i+rmax[i]]);
printf("%d\n",ans);
return 0;
}

bzoj4525:二分答案+贪心判断。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,s,t) for(int i=s;i<=t;i++)
#define clr(x,c) memset(x,c,sizeof(x))
const int nmax=50005;
int a[nmax],n,m;
int read(){
int x=0;char c=getchar();bool f=true;
while(!isdigit(c)){
if(c=='-') f=false;c=getchar();
}
while(isdigit(c)) x=x*10+c-'0',c=getchar();
return f?x:-x;
}
bool check(int x){
int ans=0;
REP(i,1,n){
int temp=a[i];
while(a[i]-temp<=x*2&&i<=n) i++;
i--;
ans++;
}
if(ans<=m) return true;
return false;
}
int main(){
n=read(),m=read();
REP(i,1,n) a[i]=read();
sort(a+1,a+n+1);
int l=0,r=1000000000,mid,ans;
while(l<=r){
mid=(l+r)>>1;
if(check(mid)) ans=mid,r=mid-1;
else l=mid+1;
}
printf("%d\n",ans);
return 0;
}

bzoj4511:模拟。。。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int x;char c;
int read(){
x=0;c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) x=x*10+c-'0',c=getchar();
return x;
}
int a[7],n,tmp,sum=0,ans=0;
int main(){
memset(a,-1,sizeof(a));
a[0]=0;
n=read();
for(int i=1;i<=n;i++){
tmp=read();
sum+=tmp,sum%=7;
if(a[sum]!=-1) ans=max(ans,i-a[sum]);
else a[sum]=i;
}
printf("%d\n",ans);
return 0;
}

bzoj4397:模拟。。。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,s,t) for(int i=1;i<=t;i++)
int read(){
int x=0;char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) x=x*10+c-'0',c=getchar();
return x;
}
const int nmax=100005;
int a[nmax],b[nmax],c[nmax];
int main(){
int n=read(),m=read();
REP(i,1,n) {
a[i]=a[i-1],b[i]=b[i-1],c[i]=c[i-1];
int tmp=read();
if(tmp==1) a[i]++;
else if(tmp==2) b[i]++;
else c[i]++;
}
REP(i,1,m){
int s=read(),t=read();
printf("%d %d %d\n",a[t]-a[s-1],b[t]-b[s-1],c[t]-c[s-1]);
}
return 0;
}

bzoj4396:简单递推题。。。

#include<cstdio>
#include<iostream>
using namespace std;
const int nmax=100005;
bool vis[nmax];
int read(){
int x=0;char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) x=x*10+c-'0',c=getchar();
return x;
}
int main(){
int n=read();
for(int i=1;i<=n;i++) vis[read()]=true;
n+=n;
int l=1,ans=0;
for(int i=1;i<=n;i++) if(!vis[i]){
while(!vis[l]) l++;
if(l<i) l++,ans++;
}
printf("%d\n",ans);
return 0;
}

  

usaco /the second wave的更多相关文章

  1. usaco /the first wave

    bzoj1572:贪心.先按时间顺序排序,然后用优先队列,如果时间不矛盾直接插入,否则判断队列中w最小的元素是否替换掉.(没用llWA了一次 #include<cstdio> #inclu ...

  2. 3408: [Usaco2009 Oct]Heat Wave 热浪

    3408: [Usaco2009 Oct]Heat Wave 热浪 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 67  Solved: 55[Subm ...

  3. RIFF和WAVE音频文件格式

    RIFF file format RIFF全称为资源互换文件格式(Resources Interchange File Format),是Windows下大部分多媒体文件遵循的一种文件结构.RIFF文 ...

  4. USACO . Your Ride Is Here

    Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often co ...

  5. IEEE 802.11p (WAVE,Wireless Access in the Vehicular Environment)

    IEEE 802.11p(又称WAVE,Wireless Access in the Vehicular Environment)是一个由IEEE 802.11标准扩充的通讯协定.这个通讯协定主要用在 ...

  6. 【USACO 3.1】Stamps (完全背包)

    题意:给你n种价值不同的邮票,最大的不超过10000元,一次最多贴k张,求1到多少都能被表示出来?n≤50,k≤200. 题解:dp[i]表示i元最少可以用几张邮票表示,那么对于价值a的邮票,可以推出 ...

  7. USACO翻译:USACO 2013 NOV Silver三题

    USACO 2013 NOV SILVER 一.题目概览 中文题目名称 未有的奶牛 拥挤的奶牛 弹簧牛 英文题目名称 nocow crowded pogocow 可执行文件名 nocow crowde ...

  8. USACO翻译:USACO 2013 DEC Silver三题

    USACO 2013 DEC SILVER 一.题目概览 中文题目名称 挤奶调度 农场航线 贝西洗牌 英文题目名称 msched vacation shuffle 可执行文件名 msched vaca ...

  9. USACO翻译:USACO 2014 DEC Silver三题

    USACO 2014 DEC SILVER 一.题目概览 中文题目名称 回程 马拉松 奶牛慢跑 英文题目名称 piggyback marathon cowjog 可执行文件名 piggyback ma ...

随机推荐

  1. hadoop中遇到的问题。

    1.物理主机中无法访问管理界面,在虚拟主机中可以访问, 这跟防火墙有关系,重启一下防火墙,然后关闭,最后重启一下handoop,应该就可以了!!!!(hadoop首战顺利!!!!!(●'◡'●))

  2. what is WLAN ? when and why we need use it ?

    无线局域网络(Wireless Local Area Networks: WLAN)是相当便利的数据传输系统,它利用射频(Radio Frequency: RF)的技术,取代旧式碍手碍脚的双绞铜线(C ...

  3. C语言多线程编程

    HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, DWORD dwStackSize, LPTHREAD_START_ROUT ...

  4. CodeForces 492B

    Description Vanya walks late at night along a straight street of length l, lit by n lanterns. Consid ...

  5. Sybase ASE安装过程报错,无法创建数据库设备[AM fork() failed]

    今天同事要搭建一套测试环境,安装开发版的SYBASE ASE 15.03 Windows平台下的,发现安装过程中到了创建数据库设备的环节就开始报错了,报错信息如下: 03/24/14 09:31:44 ...

  6. NGUI系列教程八(监听NGUI的事件方法)

    NGUI事件的种类很多,比如点击.双击.拖动.滑动等等,他们处理事件的原理几乎万全一样,本文只用按钮来举例. 1.直接监听事件 把下面脚本直接绑定在按钮上,当按钮点击时就可以监听到,这种方法不太好很不 ...

  7. 【BZOJ 1951】 [Sdoi2010]古代猪文

    Description “在那山的那边海的那边有一群小肥猪.他们活泼又聪明,他们调皮又灵敏.他们自由自在生活在那绿色的大草坪,他们善良勇敢相互都关心……” ——选自猪王国民歌 很久很久以前,在山的那边 ...

  8. 解决mybatis查询返回结果值串查

    方式一: 通过as 指定 大写重名列的 别名 方式二: 命名数据库中表名时 每个表的主键 id 要起不同的名称, 避免主键重复(但是子表的外键可以和主表的id主键重名, 你想啊, 从表的外键性质不就是 ...

  9. python学习笔记2(变量)

    变量是只不过保留的内存位置用来存储值,这意味着,当创建一个变量,那么它在内存中保留一些空间. Python是弱类型,无需明确指定变量类型,赋值的同时会自动声明类型. x = 1 y = 2.0 nam ...

  10. Xcode 向6.0以后版本添加iOS开发空白模板

    打开finder,找到应用程序,找到xcode 右键显示包内容.按照如下目录进行查找:Contents ▸ Developer ▸ Platforms ▸ iPhoneOS.platform ▸ De ...