結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー agatan
提出日時 2015-05-08 22:39:41
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,703 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 66,540 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 11:34:58
合計ジャッジ時間 1,641 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <climits>
#include <array>

#define REP(i, n) for(int i=0;i<(n);i++)

using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    std::array<char, 14> arr;
    REP(i, 14) {
        cin >> arr[i];
    }
    vector<pair<char, int>> days;
    int i = 0;
    int j = 0;
    for(auto d: arr) {
        if (d == 'o') {
            if (j > 0) {
                days.emplace_back('x', j);
                j = 0;
            }
            i++;
        }  else {
            if (i > 0) {
                days.emplace_back('o', i);
                i = 0;
            }
            j++;
        }
    }
    if (i > 0) {
        days.emplace_back('o', i);
        i = 0;
    }
    if (j > 0) {
        days.emplace_back('x', j);
        j = 0;
    }
    int idx = 0;
    int m = 0;
    while (idx < days.size()) {
        if (days[idx].first == 'o') {
            int k = days[idx].second;
            if (idx + 1 < days.size() && days[idx + 1].second <= D) {
                k += days[idx + 1].second;
                if (idx + 2 < days.size()) {
                    k += days[idx + 2].second;
                }
            }
            m = max(m, k);
            idx++;
        } else {
            int d = D;
            int k = 0;
            if (days[idx].second <= d) {
                d -= days[idx].second;
                k += days[idx].second;
                if(idx + 1 < days.size()) {
                    k += days[idx + 1].second;
                }
            }
            m = max(m, k);
            idx++;
        }
    }
    cout << m << endl;

    return 0;
}
0