結果
| 問題 | No.3210 Fixed Sign Sequense |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-05-02 12:42:47 |
| 言語 | C++23(gnu拡張) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 821 bytes |
| 記録 | |
| コンパイル時間 | 2,245 ms |
| コンパイル使用メモリ | 335,640 KB |
| 実行使用メモリ | 10,420 KB |
| 最終ジャッジ日時 | 2026-05-02 12:42:55 |
| 合計ジャッジ時間 | 4,530 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
using i32 = int;
using i64 = long long;
#define int i64
signed main() {
int n;
cin >> n;
string s;
cin >> s;
vector<int> conv(n);
int actual = 1;
for (int i = 0; i < n; i++){
if (s[i] == '+') {
conv[i] = actual++;
}
}
actual = -1;
for (int i = n - 1; i >= 0; i--) {
if (s[i] == '-') {
conv[i] = actual--;
}
}
vector<int> vals;
vals.push_back(conv[0]);
for (int i = 1; i < n; i++) {
if (vals.back() < conv[i]) {
vals.push_back(conv[i]);
continue;
}
int pos = upper_bound(vals.begin(), vals.end(), conv[i]) - vals.begin();
vals[pos] = conv[i];
}
cout << vals.size() << endl;
}
vjudge1