結果

問題 No.3210 Fixed Sign Sequense
ユーザー よには
提出日時 2025-07-25 22:00:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 866 bytes
コンパイル時間 4,444 ms
コンパイル使用メモリ 335,192 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-25 22:00:40
合計ジャッジ時間 5,989 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#if __has_include(<yoniha/all.h>)
#include <yoniha/all.h>
using namespace atcoder;
#else
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#endif
using namespace std;

#define int long long
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)((n) - 1); i >= 0; i--)
template <typename T> bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template <typename T> bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

// using mint = modint;

signed main(){
  int n; string s; cin >> n >> s;
  int ans = 0;
  int cnt_m = 0, cnt_p = 0;
  for(auto c : s) cnt_p += c == '+';
  for(auto c : s){
   	cnt_p -= c == '+';
  	chmax(ans, cnt_m + cnt_p + 1);
  	cnt_m += c == '-';
  }
  cout << ans << '\n';
}
0