結果
| 問題 | No.3210 Fixed Sign Sequense | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-07-25 23:30:05 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,061 bytes | 
| コンパイル時間 | 2,661 ms | 
| コンパイル使用メモリ | 279,408 KB | 
| 実行使用メモリ | 15,412 KB | 
| 最終ジャッジ日時 | 2025-07-25 23:30:11 | 
| 合計ジャッジ時間 | 4,372 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 32 WA * 6 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
void testcase()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<int> list_minus(N + 1, 0), list_zero(N + 1, 0), list_plus(N + 1, 0);
	for (int i = 0; i < N; i++)
	{
		list_minus[i + 1] = list_minus[i] + (S[i] == '-' ? 1 : 0);
		list_zero[i + 1] = list_zero[i] + (S[i] == '0' ? 1 : 0);
		list_plus[i + 1] = list_plus[i] + (S[i] == '+' ? 1 : 0);
	}
	int total_plus = list_plus[N];
	vector<int> next_zero(N + 1), next_plus(N + 1);
	next_zero[N] = next_plus[N] = N;
	for (int i = N - 1; i >= 0; --i)
	{
		if (S[i] == '0')
			next_zero[i] = i;
		else
			next_zero[i] = next_zero[i + 1];
		if (S[i] == '+')
			next_plus[i] = i;
		else
			next_plus[i] = next_plus[i + 1];
	}
	int max_count = 0;
	for (int i = 1; i < N; i++)//diff[i = 0 -> i = 1]
	{
		int count = 1 + list_minus[i-1] + list_plus[N]-list_plus[i];//diff
		max_count = max(max_count, count);
	}
	cout << max_count << '\n';
}
int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	testcase();
	return 0;
}
            
            
            
        