結果
| 問題 |
No.3210 Fixed Sign Sequense
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-25 22:05:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 1,292 bytes |
| コンパイル時間 | 3,261 ms |
| コンパイル使用メモリ | 279,284 KB |
| 実行使用メモリ | 8,384 KB |
| 最終ジャッジ日時 | 2025-07-25 22:05:59 |
| 合計ジャッジ時間 | 5,362 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
/*
ショトカ登録
cin cout endl return void
int double string char
pair make_pair first second tuple make_tuple get
sort erase swap map set insert
stoi reverse to_string
auto bool true false
vector queue priority_queue front pop_frpnt
size substr push_back pop_back push pop top
if for while break continue next_permutation
__builtin_popcount
*/
//無限
int inf = 1020304050;
int64_t INF = 1020304050607080900;
//モッド
int64_t mod = 998244353;
//all マクロ
#define all(v) v.begin(), v.end()
//int64_t
typedef int64_t lint;
int main () {
//少数以下
cout << fixed << setprecision(15);
lint N; cin >> N;
string S; cin >> S;
vector<lint> U(N, 0), D(N,0);
for (lint i = 0; i < N; i++) {
if (S[i] == '+') U[i]++;
if (S[i] == '-') D[i]++;
}
for (lint i = N - 2; i >= 0; i--) U[i] += U[i + 1];
for (lint i = 0; i < N - 1; i++) D[i + 1] += D[i];
lint MAX = 0;
for (lint i = -1; i < N; i++) {
lint c = 0;
if (i >= 0) c += D[i];
if (i + 1 < N) c += U[i + 1];
if ((i >= 0 && S[i] == '0') || (i + 1 < N && S[i + 1] == '0')) c++;
MAX = max(MAX, c);
}
cout << MAX << endl;
//for (auto x : U) cout << x << ' ';
//*/
}