結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー beet
提出日時 2018-08-06 17:07:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 680 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 167,316 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 18:17:04
合計ジャッジ時間 2,858 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int d;
  cin>>d;
  string s,t;
  cin>>s>>t;
  s+=t;

  auto calc=
    [](string s){
      Int n=s.size();
      Int res=0;
      for(Int i=0;i<n;i++){
	Int j=i;
	while(j<n&&s[j]=='o') j++;
	chmax(res,j-i);
      }
      return res;
    };
  
  Int n=s.size();
  Int ans=0;
  for(Int i=0;i<n;i++){
    t=s;
    for(Int j=0;j<d&&i+j<n;j++)
      t[i+j]='o';
    chmax(ans,calc(t));
  }
  cout<<ans<<endl;
  return 0;
}
0