結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
|
提出日時 | 2015-06-13 01:42:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 869 bytes |
コンパイル時間 | 1,676 ms |
コンパイル使用メモリ | 161,040 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 11:47:29 |
合計ジャッジ時間 | 3,168 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) int solve(int D, const string &s){ int d = 99; vector<int> v; REP(i,14){ if(s[i] == 'x'){ if(d > 0) d++; else { v.push_back(d); d = +1; } } else { if(d < 0) d--; else { v.push_back(d); d = -1; } } } if(d < 0) v.push_back(d); v.push_back(99); int n = v.size(); if(n == 1) return D; int res = 0; for(int i = 0; i < n; i += 2){ if(v[i] > D){ if(i > 0) res = max(res, -v[i-1]+D); if(i < n-1) res = max(res, -v[i+1]+D); } else { res = max(res, v[i]-v[i-1]-v[i+1]); } } return res; } int main(){ int D; cin >> D; string s,t; cin >> s >> t; s += t; cout << solve(D,s) << endl; return 0; }