結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
|
提出日時 | 2025-07-26 00:05:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 1,859 ms |
コンパイル使用メモリ | 165,416 KB |
実行使用メモリ | 8,288 KB |
最終ジャッジ日時 | 2025-07-26 00:05:23 |
合計ジャッジ時間 | 3,624 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; #define REP(i,n) for(ll i=0;i<ll(n);i++) int main(void){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll i,j; ll N; string S; cin >> N >> S; vector<ll> m(N+2,0),p(N+2,0); for(i=1;i<=N;i++){ if(S[i-1]=='-') m[i]=m[i-1]+1; else m[i]=m[i-1]; } for(i=N;i>=1;i--){ if(S[i-1]=='+') p[i]=p[i+1]+1; else p[i]=p[i+1]; } ll ans=1; for(i=0;i<N;i++){ if(S[i]=='0') ans=max(ans,m[i+1]+p[i+1]+1); else ans=max(ans,m[i+1]+p[i+1]); } cout << ans << endl; return 0; }