結果

問題 No.576 E869120 and Rings
ユーザー ats5515ats5515
提出日時 2017-10-13 22:40:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 173 ms / 1,500 ms
コード長 997 bytes
コンパイル時間 751 ms
コンパイル使用メモリ 82,552 KB
実行使用メモリ 28,828 KB
最終ジャッジ日時 2023-08-11 00:27:05
合計ジャッジ時間 5,848 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
27,400 KB
testcase_01 AC 161 ms
28,416 KB
testcase_02 AC 168 ms
27,872 KB
testcase_03 AC 172 ms
27,920 KB
testcase_04 AC 172 ms
28,048 KB
testcase_05 AC 173 ms
28,160 KB
testcase_06 AC 171 ms
28,644 KB
testcase_07 AC 172 ms
27,912 KB
testcase_08 AC 166 ms
27,216 KB
testcase_09 AC 165 ms
27,500 KB
testcase_10 AC 166 ms
28,276 KB
testcase_11 AC 163 ms
27,588 KB
testcase_12 AC 165 ms
27,680 KB
testcase_13 AC 162 ms
27,448 KB
testcase_14 AC 173 ms
28,428 KB
testcase_15 AC 142 ms
28,136 KB
testcase_16 AC 163 ms
28,420 KB
testcase_17 AC 163 ms
27,228 KB
testcase_18 AC 166 ms
27,496 KB
testcase_19 AC 167 ms
28,124 KB
testcase_20 AC 163 ms
28,828 KB
testcase_21 AC 166 ms
28,488 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<int> A;
vector<double> B;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	A.resize(2 * N);
	B.resize(2 * N + 1);
	string S;
	cin >> S;

	for (int i = 0; i < N; i++) {
		A[i] = (int)(S[i]-'0');
		A[i + N] = A[i];
	}
	A.push_back(0);
	double u = 1;
	double d = 0;
	double m;
	double mx;
	bool f;
	while (u-d>1e-8) {
		
		m = (u + d) / 2;
		mx = 0;
		f = false;
		B[0] = m - A[0];
		for (int i = 1; i < 2 * N + 1; i++) {
			B[i] = B[i - 1] - A[i];
			B[i] += m;
		}
		for (int i = K - 1; i < 2 * N + 1; i++) {
			
			if (i >= K) {
				mx = max(mx, B[i - K]);
			}
			if (B[i] < mx) {
				f = true;
				break;
			}
		}
		if (f) {
			d = m;
		}
		else {
			u = m;
		}
	}
	cout << setprecision(10) << m << endl;
}
0