結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
|
提出日時 | 2025-07-25 21:27:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 366 bytes |
コンパイル時間 | 2,945 ms |
コンパイル使用メモリ | 278,276 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-25 21:27:13 |
合計ジャッジ時間 | 4,597 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int n; string s; cin >> n >> s; vector<int> p(n+1, 0), m(n+1, 0); for(int i=0; i<n; i++){ p[i+1] += p[i]; m[i+1] += m[i]; if(s[i] == '+') p[i+1]++; if(s[i] == '-') m[i+1]++; } int ans = 0; for(int i=0; i<=n; i++){ ans = max(ans, m[i]+p[n] - p[i] + (s[i] == '0')); } cout << ans << endl; }