結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
|
提出日時 | 2025-07-25 21:51:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 703 bytes |
コンパイル時間 | 769 ms |
コンパイル使用メモリ | 95,792 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-25 21:51:48 |
合計ジャッジ時間 | 2,263 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 WA * 26 |
ソースコード
#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 '1': 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; }