結果
問題 |
No.204 ゴールデン・ウィーク(2)
|
ユーザー |
![]() |
提出日時 | 2016-07-13 09:36:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 839 bytes |
コンパイル時間 | 958 ms |
コンパイル使用メモリ | 67,644 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 11:55:34 |
合計ジャッジ時間 | 2,159 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
ソースコード
#include <iostream> #include <string> #include <algorithm> int main() { int d, max = 0; std::string s, s2; std::cin >> d >> s >> s2; s += s2; // 前と後ろに平日を追加する for (int i = 0; i < 14; i++) { s.insert(0, "x"); s += "x"; } for (int i = 0; i < s.length() - d + 1; i++) { // i日目から有給休暇を取る int remain_holiday = d, j = i; std::string day = s; while (remain_holiday != 0 && j < s.length()) { if (day[j] == 'x') { day[j] = 'o'; remain_holiday--; } else { break; } j++; } // std::cout << day << std::endl; int holiday = 0; for (j = 0; j < s.length(); j++) { if(day[j] == 'o'){ holiday++; } else { max = std::max(max, holiday); holiday = 0; } } max = std::max(max, holiday); } std::cout << max << std::endl; return 0; }