結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
|
提出日時 | 2025-07-26 00:00:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 592 bytes |
コンパイル時間 | 1,609 ms |
コンパイル使用メモリ | 165,836 KB |
実行使用メモリ | 8,412 KB |
最終ジャッジ日時 | 2025-07-26 00:00:45 |
合計ジャッジ時間 | 3,358 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 WA * 14 |
ソースコード
#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') continue; ans=max(ans,m[i+1]+p[i+1]+1); } cout << ans << endl; return 0; }