結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
|
提出日時 | 2025-06-29 11:10:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 616 bytes |
コンパイル時間 | 767 ms |
コンパイル使用メモリ | 87,720 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-25 20:41:30 |
合計ジャッジ時間 | 2,462 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 29 WA * 9 |
ソースコード
#include<iostream> #include<vector> using namespace std; int main(){ int N; string S; cin >> N >> S; vector<int> minus(N+2,0),plus(N+2,0);//Sの0~i文字目までに何個'-'があるか/Sのi~N-1文字目までに何個'+'があるか for(int j = 0; j < N; j++){ minus[j+1] = minus[j]; if(S[j] == '-')minus[j+1]++; } for(int j = N-1; j >= 0; j--){ plus[j+1] = plus[j+2]; if(S[j] == '+')plus[j+1]++; } int ans = 0; for(int j = 0; j < N; j++){ ans = max(ans,minus[j-1] + 1 + plus[j+1]); } cout << ans << endl; return 0; }