天呢,这个题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 ;
}

最新文章

  1. 修改 Ueditor 默认显示的字体大小
  2. Ubuntu中NetBeans C/C++配置、编译
  3. 让footer固定在页面(视口)底部(CSS-Sticky-Footer)
  4. smarty练习:考试系统
  5. SE 2014年4月8日
  6. swust oj 972
  7. Foundations of Game Engine Development Volume 1 Mathematics (Eric Lengyel 著)
  8. python 第三方扩展库的安装
  9. go map的使用
  10. jumpserver修改默认管理员账号名
  11. imp导入备份时报:无法转换为环境字符集句柄
  12. k8s删除一个Node并重新加入集群
  13. poj 2785 让和为0 暴力&amp;二分
  14. TStream实现多表提交
  15. Windows 虚拟桌面工具 Desktops v2.0
  16. 关于PHP的特点
  17. scikit_learn 中文说明入门
  18. 洛谷P2731 骑马修栅栏 [欧拉回路]
  19. Java Web项目在Mac系统上启动时提示nodename nor servname provided
  20. bundle绑定资源表

热门文章

  1. android-------手写签名系统的设计与实现之实现画笔设置
  2. POJ 1511 Invitation Cards 正反SPFA
  3. CentOS 在同一窗口打开文件夹
  4. SDAU课程练习--problemB(1001)
  5. openwrt串口的使用
  6. Chapter 1 First Sight——4
  7. js url编码函数
  8. Bluez SPP实现代码分析(转)
  9. 15个最佳jQuery的翻页书效果的例子
  10. Mac下eclipse导入其他工程中文注释出现乱码解决方案