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