結果
| 問題 |
No.2145 Segment +-
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2022-12-02 23:13:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 550 bytes |
| コンパイル時間 | 1,834 ms |
| コンパイル使用メモリ | 192,500 KB |
| 最終ジャッジ日時 | 2025-02-09 04:22:58 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n;
string s;
cin >> n >> s;
char p = '+';
int x = 0, y = 0, r = 0;
s.push_back('+');
for (int i = 0; i <= n; i++) {
if (s[i] != '-') {
if (x < 0) {
x += (y - x) * 2;
r++;
y = 0;
}
x++;
y = max(y, x);
p = '+';
} else {
x--;
p = '-';
}
}
cout << r << endl;
return 0;
}
merom686