結果
| 問題 |
No.3210 Fixed Sign Sequense
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-25 21:53:42 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 703 bytes |
| コンパイル時間 | 647 ms |
| コンパイル使用メモリ | 95,552 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-07-25 21:53:47 |
| 合計ジャッジ時間 | 1,942 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <iostream>
#include <cstdint>
#include <algorithm>
static inline constexpr uint_fast32_t solve(const uint_fast32_t N, const std::string& S) noexcept
{
uint_fast32_t len_neg = 0, len_zero = 0, len_pos = 0;
for (uint_fast32_t i = 0; i != N; ++i)
switch(S[i])
{
case '-':
++len_neg;
break;
case '0':
len_zero = len_neg + 1;
break;
case '+':
len_pos = std::max({ len_neg, len_zero, len_pos }) + 1;
break;
}
return std::max({ len_neg, len_zero, len_pos });
}
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
uint_fast32_t N;
std::string S;
std::cin >> N;
S.reserve(N), std::cin >> S;
std::cout << solve(N, S) << '\n';
return 0;
}