天呢,这个题2333333,真是被各种卡。完蛋完蛋完蛋。IQ------------;

 #include<bits/stdc++.h>
#define lowbit(x) x&(-x)
#define LL long long
#define N 100005
#define M 1000005
#define mod 2147483648LL
#define inf 0x7ffffffff
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>''){if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<=''){x=x*+ch-''; ch=getchar();}
return x*f;
}
int n,k,last,ans,cnt;
int a[N<<],b[N<<];
int main()
{
n=ra(); k=ra();
for (int i=; i<=n; i++) a[i]=ra();
int last,start=n+;
for (int i=; i<=n; i++)
if (a[i]<) {
start=i;
break;
}
if (start<=n) ans=,k--;
else {
cout<<"";
return ;
}
for (int i=start+; i<=n; i++)
{
if (a[i]<) k--;
if (a[i]>= && a[i-]<) last=i,ans++;
if (a[i]>= && a[i+]<) b[++cnt]=i-last+,ans++;
}
if (k<)
{
cout<<"-1";
return ;
}
sort(b+,b+cnt+);
for (int i=; i<=cnt; i++)
if (k-b[i]<) break;
else k-=b[i],ans-=;
if (a[n]>=)
for (int i=n; i>=; i--)
if (a[i]<)
{
b[++cnt]=n-i;
break;
}
if (b[cnt]<=k && cnt) ans--;
cout<<ans;
return ;
}

cf747 D. Winter Is Coming的更多相关文章

  1. 开发框架Data Abstract和Hydra发布版本Winter 2013

    Data Abstract Winter 2013即Data Abstract Version 7.0.73 (Build .1111),Winter 2013版对Data Abstract继续做了以 ...

  2. 2015 UESTC Winter Training #10【Northeastern Europe 2009】

    2015 UESTC Winter Training #10 Northeastern Europe 2009 最近集训都不在状态啊,嘛,上午一直在练车,比赛时也是刚吃过午饭,状态不好也难免,下次比赛 ...

  3. 2015 UESTC Winter Training #8【The 2011 Rocky Mountain Regional Contest】

    2015 UESTC Winter Training #8 The 2011 Rocky Mountain Regional Contest Regionals 2011 >> North ...

  4. 2015 UESTC Winter Training #7【2010-2011 Petrozavodsk Winter Training Camp, Saratov State U Contest】

    2015 UESTC Winter Training #7 2010-2011 Petrozavodsk Winter Training Camp, Saratov State U Contest 据 ...

  5. 2015 UESTC Winter Training #6【Regionals 2010 >> North America - Rocky Mountain】

    2015 UESTC Winter Training #6 Regionals 2010 >> North America - Rocky Mountain A - Parenthesis ...

  6. 2015 UESTC Winter Training #4【Regionals 2008 :: Asia - Tehran】

    2015 UESTC Winter Training #4 Regionals 2008 :: Asia - Tehran 比赛开始时电脑死活也连不上WIFI,导致花了近1个小时才解决_(:зゝ∠)_ ...

  7. Winter(bfs&&dfs)

    1084 - Winter   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Winter is ...

  8. Codeforces 839D Winter is here【数学:容斥原理】

    D. Winter is here time limit per test:3 seconds memory limit per test:256 megabytes input:standard i ...

  9. Codeforces Round #428 (Div. 2) D. Winter is here 容斥

    D. Winter is here 题目连接: http://codeforces.com/contest/839/problem/D Description Winter is here at th ...

随机推荐

  1. android脚步---Itent.ACTION_PICK ,startActivityForResult

    public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(Intent.A ...

  2. 1058FBI<二叉树,递归,后序遍历>

    问题描述 我们可以把由"0"和"1"组成的字符串分为三类:全"0"串称为B串,全"1"串称为I串,既含"0&q ...

  3. Finance

    转载自:http://blog.csdn.net/xiajun07061225/article/details/13346733

  4. copy-on-write学习

    最近知识梳理不够,那就整理点以前blog的东西.这儿就看COW(copy-on-write),cow技术主要是为了提高程序在单步操作时的系统响应速度而设计的,它通过将不是立即必要的空间分配,数据复制等 ...

  5. SecureCRT上传bash: rz: command not found

    SecureCRT上传bash: rz: command not found -bash: rz: command not found rz命令没找到? 执行sz,同样也没找到.     安装lrzs ...

  6. Bar Chart of Frequency of modals in different sections of the Brown Corpus

    Natural Language Processing with Python Chapter 4.8 colors = 'rgbcmyk' # red, green, blue, cyan, mag ...

  7. hibernate---一级缓存, 二级缓存, 查询缓存

    缓存: 内存开辟一块空间,把本来存在硬盘的东西放在内存里, 以后从内存读取. 一级缓存: session级别的缓存, session.load 二级缓存: 总的缓存.

  8. 一、Hadoop基本操作命令

    查看hadoop版本 hadoop version 启动与关闭 启动Hadoop 1.         进入HADOOP_HOME目录. 2.         执行sh bin/start-all.s ...

  9. CodeForces 652A Gabriel and Caterpillar

    简单模拟. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

  10. MYSQL-group_concat设置group_concat_max_len

    MySQL提供的group_concat函数可以拼接某个字段值成字符串,如 select group_concat(user_name) from sys_user,默认的分隔符是 逗号,即" ...