結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
![]() |
提出日時 | 2015-05-08 23:02:51 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,081 bytes |
コンパイル時間 | 757 ms |
コンパイル使用メモリ | 83,648 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 11:37:20 |
合計ジャッジ時間 | 2,090 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include<sstream> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<numeric> #include<functional> #include<algorithm> using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) #define indexOf(v,x) (find(all(v),x)-v.begin()) int main(){ char c[14]; int ans,len=0,d; vector<pair<int,int> > v; cin>>d; ans=d; rep(i,14)cin>>c[i]; rep(i,14){ if(c[i]=='o')len++; else if(len){ v.push_back(make_pair(i-len,i-1)); len=0; } ans=max(ans,len); } if(len)v.push_back(make_pair(14-len,14-1)); rep(i,(int)v.size()-1){ if(v[i+1].first-v[i].second-1<=d){ ans=max(ans,v[i+1].second-v[i].first+1); }else{ ans=max(ans,max(v[i].second-v[i].first,v[i+1].second-v[i+1].first)+1+d); } } if(v.size()){ ans=max(ans,v[0].second-v[0].first+1+d); ans=max(ans,v.back().second-v.back().first+1+d); } cout<<ans<<endl; return 0; }