結果

問題 No.576 E869120 and Rings
ユーザー ミドリムシミドリムシ
提出日時 2017-10-13 23:01:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,035 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 63,088 KB
実行使用メモリ 13,884 KB
最終ジャッジ日時 2024-04-28 17:41:19
合計ジャッジ時間 7,545 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 17 ms
5,376 KB
testcase_14 AC 19 ms
5,376 KB
testcase_15 AC 15 ms
5,376 KB
testcase_16 AC 15 ms
5,376 KB
testcase_17 AC 19 ms
5,376 KB
testcase_18 AC 17 ms
5,376 KB
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
using namespace std;
 
int main(){
	int N, K;
	string jewelry;
	cin >> N >> K >> jewelry;
	int blue_gem = 0;
	for(int i = 0; i < K; i++){
		blue_gem += jewelry[i] - '0';
	}
	double ans = 0;
	bool if_retrieval[N];
	for(int i = 0; i < N; i++){
		if_retrieval[i] = true;
	}
	for(int i = 0; i < N; i++){
		if(!if_retrieval[i]){
			continue;
		}
		blue_gem -= jewelry[(i - 1 + N) % N] - '0';
		blue_gem += jewelry[(i + K - 1 + N) % N] - '0';
		int blue_gem_plus = 0;
		for(int j = 1; j + K - 1 < N; j++){
			if(jewelry[(i - j + N) % N] == '0'){
				break;
			}
			blue_gem_plus++;
			if_retrieval[(i - j + N) % N] = false;
		}
		int plus_i = 0;
		for(int j = 1; j + K - 1 < N; j++){
			if(jewelry[(i + K + j - 1 + N) % N] == '0'){
				break;
			}
			blue_gem_plus++;
			plus_i++;
			if_retrieval[(i + j) % N] = false;
		}
		i += plus_i;
		double ans_tmp = (blue_gem_plus + blue_gem) / double(blue_gem_plus + K);
		if(ans < ans_tmp){
			ans = ans_tmp;
		}
	}
	cout << setprecision(10) << ans << endl;
}
0