记录编号 |
122283 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
[東方S3] 比那名居天子 |
最终得分 |
100 |
用户昵称 |
HouJikan |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.211 s |
提交时间 |
2014-09-23 07:51:31 |
内存使用 |
0.30 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <iterator>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <functional>
#include <deque>
#define For(i,j,k) for(int i=(j);i<=(k);i++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint;
const int INF=0x7ffffff;
using namespace std;
//================struct declaration======================
//================var declaration=-========================
int n,k;
int Low,High,Mid;
string road;
//================function declaration====================
bool repair(int len,string s);
//================main code===============================
int main()
{
string ProgrammeName="tenshi";
string FloderName="COGS";
freopen((ProgrammeName+".in").c_str(),"r",stdin);
freopen((ProgrammeName+".out").c_str(),"w",stdout);
#ifdef DEBUG
clock_t Start_Time=clock();
system(("copy C:\\Users\\abc\\Desktop\\HouJikan\\"+FloderName+"\\standard.cpp C:\\Users\\abc\\Desktop\\HouJikan\\"+FloderName+"\\submit.txt").c_str());
#endif
cin>>n>>k>>road;
Low=0,High=n/k+1;
while (Low<High)
{
Mid=(Low+High)>>1;
if (repair(Mid,road))
High=Mid;
else
Low=Mid+1;
}
printf("%d\n",Low);
#ifdef DEBUG
clock_t End_Time=clock();
printf("\n\nTime Used :%.6lf Ms\n",double(Start_Time-End_Time)/(-CLOCKS_PER_SEC));
#endif
return 0;
}
//================function code===========================
bool repair(int len,string s)
{
For(i,1,k)
{
int p=s.find('1');
if (p==string::npos)
return true;
for(int j=p;j<=p+len-1&&j<n;j++)
s[j]='0';
}
return s.find('1')==string::npos;
}