結果

問題 No.3210 Fixed Sign Sequense
ユーザー srjywrdnprkt
提出日時 2025-07-28 16:39:29
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 650 bytes
コンパイル時間 3,008 ms
コンパイル使用メモリ 278,748 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-28 16:39:35
合計ジャッジ時間 5,508 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/modint>

using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint998244353;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> LM(N+2), RP(N+2);
    for (int i=1; i<=N; i++){
        if (S[i-1] == '-') LM[i]++;
        LM[i] += LM[i-1];
    }
    for (int i=N; i>=1; i--){
        if (S[i-1] == '+') RP[i]++;
        RP[i] += RP[i+1];
    }
    int ans=0;
    for (int i=1; i<=N; i++){
        ans = max(ans, LM[i-1]+RP[i+1]+1);
    }

    cout << ans << endl;

    return 0;
}
0