結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー hanorver
提出日時 2016-07-13 09:27:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 69,016 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-14 15:33:23
合計ジャッジ時間 1,919 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 27 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>

int main() {
	int d, max = 0;
	std::string s, s2;

	std::cin >> d >> s >> s2;

	s += s2;

	// 前と後ろに平日を追加する
	for (int i = 0; i < 14; i++) {
		s.insert(0, "x");
		s += "x";
	}

	for (int i = 0; i < s.length() - d + 1; i++) {
		// i日目から有給休暇を取る
		int remain_holiday = d, j = i;
		std::string day = s;

		while (remain_holiday != 0 && j < s.length()) {
			if (day[j] == 'x') {
				day[j] = 'o';
				remain_holiday--;
			} else {
				break;
			}
			j++;
		}
		//std::cout << day << std::endl;
		int holiday = 0;
		for (int j = 0; j < s.length() - i + 1; j++) {
			if(day[j] == 'o'){
				holiday++;
			} else {
				max = std::max(max, holiday);
				holiday = 0;
			}
		}
		max = std::max(max, holiday);
	}

	std::cout << max << std::endl;

	return 0;
}
0