結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー koyumeishi
提出日時 2015-05-08 23:37:09
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 915 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 78,348 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 11:55:23
合計ジャッジ時間 1,693 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

int main(){
	int d;
	cin >> d;
	string a,b;
	cin >> a >> b;

	string c = "xxxxxxx";

	string s = c+c;
	s += a;
	s += b;
	s += c+c;

	vector<int> begin;
	vector<int> end;
	int last = -100;
	int tmp = 0;
	for(int i=0; i<s.size(); i++){
		if(s[i] == 'o'){
			if(last == i-1){

			}else{
				begin.push_back(i);

			}
			last = i;
		}else if(last == i-1){
			end.push_back(i-1);
		}
	}

	int ans = 0;
	if(begin.size() == 0){
		ans = d;
	}else{
		ans = end[0] - begin[0] + 1 + d;
	}

	for(int i=0; i<begin.size(); i++){
		if(i+1 < begin.size() && begin[i+1] - end[i] - 1 <= d){
			ans = max(ans, end[i+1] - begin[i] + 1);
		}else{
			ans = max(ans, end[i] - begin[i] + 1 + d);
		}
	}

	cout << ans << endl;

	return 0;
}
0