Enduring Exodus CodeForces - 655C (二分)

链接

大意: n个房间, 1为占用, 0为未占用, John要将k头奶牛和自己分进k+1个空房间, 求John距最远的奶牛距离的最小值

 

 

这种简单题卡了20min....

显然对于固定的k+1个房间, 只需要John在最接近中央的房间即可, 枚举每k个房间, 找出最接近的就行了

这样复杂度是$O(nlogk)$

还可以直接二分答案, 复杂度$O(nlogn)$

 

#include <iostream>
#include <algorithm>
#include <cstdio>
#define REP(i,a,n) for(int i=a;i<=n;++i)
using namespace std;

const int N = 4e5+10;
int n, k;
int a[N];
char s[N];

int main() {
	scanf("%d%d%s", &n, &k, s+1);
	REP(i,1,n) if (s[i]=='0') a[++*a] = i;
	n = *a;
	int ans = 1e9;
	REP(i,1,n-k) {
		int j = i+k;
		int p = lower_bound(a+i,a+j+1,(a[i]+a[j])/2)-a-1;
		REP(r,p,p+3) if (i<=r&&r<=j) {
			ans = min(ans, max(abs(a[i]-a[r]),abs(a[j]-a[r])));
		}
	}
	printf("%d\n", ans);
}

 

转载于:https://www.cnblogs.com/uid001/p/10410673.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Key Features The problems of CSS at scale - specificity, the cascade and styles intrinsically tied to element structure. The shortfalls of conventional approaches to scaling CSS. The ECSS methodology and the problems it solves. How to develop consistent and enforceable selector naming conventions with ECSS. How to organise project structure to more easily isolate and decouple visual components. Considerations of CSS tooling and processing: Sass/PostCSS and linting. Addressing the notion of CSS selector speed with hard data and browser representative insight. Book Description Learn with me, Ben Frain, about how to really THINK about CSS and how to use CSS for any size project! I'll show you how to write CSS that endures continual iteration, multiple authors, and yet always produces predictable results. Enduring CSS, often referred to as ECSS, offers you a robust and proven approach to authoring and maintaining style sheets at scale. Enduring CSS is not a book about writing CSS, as in the stuff inside the curly braces. This is a book showing you how to think about CSS, and be a smarter developer with that thinking! It's about the organisation and architecture of CSS: the parts outside the braces. I will help you think about the aspects of CSS development that become the most difficult part of writing CSS in larger projects. You ll learn about the problems of authoring CSS at scale - including specificity, the cascade and styles intrinsically tied to document structure. I'll introduce you to the ECSS methodology, and show you how to develop consistent and enforceable selector naming conventions. We'll cover how to apply ECSS to your web applications and visual models. And how you can organise your project structure wisely, and handle visual state changes with ARIA, providing greater accessibility considerations. In addition, we'll take a deep look into CSS tooling and process considerations. Finally we will address performance considerations by examining topics such as CSS selector speed with hard data and browser-representative insight. Enduring CSS is a book for considering how to write CSS in the most effective manner, and how you too can create an enduring CSS code base, regardless of project size. Take a journey with me if you want to explore these topics and deepen your thinking as a CSS author.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值