結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー |
![]() |
提出日時 | 2016-02-19 21:36:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,600 bytes |
コンパイル時間 | 811 ms |
コンパイル使用メモリ | 66,068 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-24 11:51:25 |
合計ジャッジ時間 | 1,877 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <queue> #include <algorithm> #include <vector> #include <iostream> #include <numeric> #include <tuple> using namespace std; typedef long long int ll; typedef pair<int, int> pii; typedef vector<int> vi; #define REP(i,x) for(int i=0;i<(int)(x);i++) #define ALL(container) (container).begin(), (container).end() int main(int argc, char *argv[]){ ios::sync_with_stdio(false); int n; cin >> n; string f; string s; cin >> f; cin >> s; const string m = "xxxxxxxxxxxxxx" + f + s + "xxxxxxxxxxxxxx"; int maxValue = 0; { int current = 0; for(int j = 0;j < m.length();j++) { if(m[j] == 'o') { current++; maxValue = max(maxValue, current); } else { current = 0; } } } for(int i = 0; i < m.length();i++) { if(m[i] == 'o') { continue; } int current = 0; bool seq = true; for(int j = 0;j < m.length();j++) { if(j >= i && j < i + n && seq) { if(m[j] == 'o') { seq = false; } current++; maxValue = max(maxValue, current); } else if(m[j] == 'o') { current++; maxValue = max(maxValue, current); } else { current = 0; } } } cout << maxValue << endl; return 0; }