結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー hanorver
提出日時 2015-10-23 14:54:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 836 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 58,204 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 13:40:18
合計ジャッジ時間 1,719 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int holiday;
	std::string weeks, s;

	std::cin >> holiday;
	std::cin >> s;
	weeks = s;
	std::cin >> s;
	weeks += s;

	int max = holiday;
	//ゴールデンウィークの前から有給をとる場合
	for (int i = 0; weeks[i] == 'o'; i++) {
		max++;
	}

	for (int i = 0; i < weeks.length(); i++) {
		int count = 0, holi_num = 0;
		bool flag = false;
		int j = i;
		while (j < weeks.length() && weeks[j] == 'o') {
			holi_num++;
			j++;
		}
		while (j < weeks.length() && weeks[j] == 'x' && count != holiday) {
			count++;
			holi_num++;
			j++;
		}
		while (j < weeks.length() && weeks[j] == 'o') {
			flag = true;
			holi_num++;
			j++;
		}
		if (!flag)holi_num += holiday - count;
		max = std::max(max, holi_num);
	}

	std::cout << max << std::endl;
	return 0;
}
0