結果
| 問題 | No.3210 Fixed Sign Sequense |
| コンテスト | |
| ユーザー |
zawakasu
|
| 提出日時 | 2025-07-25 21:25:17 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 1,225 bytes |
| コンパイル時間 | 1,175 ms |
| コンパイル使用メモリ | 124,080 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-07-25 21:25:39 |
| 合計ジャッジ時間 | 2,943 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <tuple>
#include <ranges>
namespace ranges = std::ranges;
namespace views = std::views;
// #include "Src/Number/IntegerDivision.hpp"
// #include "Src/Utility/BinarySearch.hpp"
// #include "Src/Sequence/CompressedSequence.hpp"
// #include "Src/Sequence/RunLengthEncoding.hpp"
// #include "Src/Algebra/Group/AdditiveGroup.hpp"
// #include "Src/DataStructure/FenwickTree/FenwickTree.hpp"
// #include "Src/DataStructure/SegmentTree/SegmentTree.hpp"
// #include "Src/DataStructure/DisjointSetUnion/DisjointSetUnion.hpp"
// using namespace zawa;
// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
using namespace std;
int N;
string S;
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
cin >> N >> S;
vector<int> dp(2, -1);
dp[0] = 0;
for (char c : S) {
vector<int> next = dp;
if (c == '-') next[0] = dp[0] + 1;
else if (c == '0') next[1] = max(dp[1], dp[0] + 1);
else if (c == '+') next[1] = max(dp[0], dp[1]) + 1;
dp = move(next);
}
cout << *ranges::max_element(dp) << '\n';
}
zawakasu