結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
|
提出日時 | 2025-07-25 21:30:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 717 bytes |
コンパイル時間 | 2,424 ms |
コンパイル使用メモリ | 198,024 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-25 21:30:20 |
合計ジャッジ時間 | 4,038 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e9 + 7; const int N = 200005; const int INF = 0x3f3f3f3f; int main() { int n; string s; cin >> n >> s; vector<int> vec; int p1 = -INF, p2 = 1; for (int i = 0; i < n; i++) { if (s[i] == '-') { vec.push_back(p1); p1++; } else if (s[i] == '+') { vec.push_back(p2); p2++; } else { vec.push_back(0); } } auto end = vec.begin(); for (auto x : vec) { auto it = lower_bound(vec.begin(), end, x); *it = x; if (it == end) end++; } cout << end - vec.begin() << "\n"; return 0; }