結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー agatanagatan
提出日時 2015-05-08 22:55:23
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,984 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 65,564 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-03 14:49:53
合計ジャッジ時間 2,258 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,376 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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()) {
                k += min(D, days[idx+1].second);
                if (days[idx+1].second <= D && idx + 2 < days.size()) {
                    k += days[idx + 2].second;
                }
            }
            m = max(m, k);
            idx++;
        } else {
            int k = 0;
            if (days[idx].second <= D) {
                k += days[idx].second;
                if(idx + 1 < days.size()) {
                    k += days[idx + 1].second;
                }
            } else {
                k += D;
                if (idx + 1 < days.size()) {
                    k += days[idx + 1].second;
                }
            }
            m = max(m, k);
            idx++;
        }
    }
    if (days[0].first == 'o') {
        m = max(m, D + days[0].second);
    }
    if (days[days.size() - 1].first == 'o') {
        m = max(m, D + days[days.size() - 1].second);
    }
    cout << m << endl;

    return 0;
}
0