結果

問題 No.3210 Fixed Sign Sequense
ユーザー Brandon Li
提出日時 2025-07-25 21:26:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 201,204 KB
実行使用メモリ 20,028 KB
最終ジャッジ日時 2025-07-25 21:27:00
合計ジャッジ時間 4,226 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
#ifdef LOCAL
#include <debug.h>
#else
#define dbg(...) 0
#define dbgn(...) 0
#endif

void solve(){
	int n; 
	cin >> n; 
	string str; 
	cin >> str; 
	vector<vector<int>> dp(n + 1, vector<int> (3)); 
	for(int i = 0; i < n; i++){
		dp[i + 1] = dp[i]; 
		if(str[i] == '+'){
			dp[i + 1][2] = max(dp[i][1] + 1, dp[i][2] + 1); 
		}
		if(str[i] == '0'){
			dp[i + 1][1] = dp[i][0] + 1; 
		}
		if(str[i] == '-'){
			dp[i + 1][0] = dp[i][0] + 1; 
		}
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << '\n'; 
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    solve(); 
    return 0; 
}
0