結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー srup٩(๑`н´๑)۶
提出日時 2016-08-19 00:48:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 676 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 58,400 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-24 11:56:46
合計ジャッジ時間 1,784 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(void){
	int n; cin >> n;
	string s1, s2; cin >> s1 >> s2;
	//与えられた14日の前後は平日が無限いつづく
	string s = "xxxxxxxxxxxxxxx" + s1 + s2 + "xxxxxxxxxxxxxxx";
	int ans = 0, tmp = 0;
	for (int i = 0; i < s.size() - n; ++i){
		tmp = 0;
		string t = s;
		for (int j = i; j < i + n; ++j){
			if(t[j] == 'x') t[j] = 'o';
			else break;
		}
		rep(j, t.size()){
			if(t[j] == 'o') tmp++;
			else{
				ans = max(tmp, ans); tmp = 0;
			}
			if(j == t.size() - 1){
				ans = max(tmp, ans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0