結果

問題 No.576 E869120 and Rings
ユーザー ryoissyryoissy
提出日時 2017-10-14 17:30:04
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 817 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 149,948 KB
実行使用メモリ 16,152 KB
最終ジャッジ日時 2023-08-11 02:27:33
合計ジャッジ時間 42,081 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,453 ms
12,200 KB
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 1,494 ms
12,340 KB
testcase_13 AC 1,298 ms
12,384 KB
testcase_14 AC 1,390 ms
12,172 KB
testcase_15 AC 1,091 ms
16,152 KB
testcase_16 AC 1,087 ms
16,152 KB
testcase_17 AC 1,371 ms
12,228 KB
testcase_18 AC 1,459 ms
12,380 KB
testcase_19 AC 1,456 ms
12,196 KB
testcase_20 AC 876 ms
12,044 KB
testcase_21 AC 1,476 ms
12,196 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 1000000007LL
#define EPS 1e-10
using namespace std;
typedef long long ll;
typedef pair<double,int> P;

int n,k;
string str;
double sum[1000001];

bool C(double vv){
	for(int i=0;i<str.size();i++){
		sum[i+1]=sum[i]-vv;
		if(str[i]=='1')sum[i+1]+=1.0;
	}
	deque<P> mx;
	for(int i=k;i<=str.size();i++){
		while(mx.size()){
			if(mx[0].second<=i-n){
				mx.pop_front();
			}else break;
		}
		while(mx.size()){
			if(mx.back().first>sum[i-k])mx.pop_back();
			else break;
		}
		mx.push_back(P(sum[i-k],i-k));
		if(mx.size() && sum[i]-mx[0].first>0.0)return true;
	}
	return false;
}

int main(void){
	scanf("%d%d",&n,&k);
	cin >> str;
	str+=str;
	double l=0.0,r=1.0;
	for(int i=0;i<100;i++){
		double mid=(l+r)/2;
		if(C(mid))l=mid;
		else r=mid;
	}
	printf("%.10f\n",l);
	return 0;
}
0