結果

問題 No.3210 Fixed Sign Sequense
ユーザー forest3
提出日時 2025-09-30 21:27:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 1,399 ms
コンパイル使用メモリ 165,792 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-30 21:27:43
合計ジャッジ時間 4,116 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
using ll = long long;

int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> a(n), d;
	int m = -1e9, p = 1;
	rep(i, 0, n) {
		if(s[i] == '0') continue;
		else {
			if(s[i] == '+') a[i] = p++;
			else a[i] = m++;
		}
	}
	rep(i, 0, n) {
		int j = lower_bound(d.begin(), d.end(), a[i]) - d.begin();
		int sz = d.size();
		if(j == sz) d.push_back(a[i]);
		else d[j] = a[i];
	}
	cout << d.size() << endl;
}
0