結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-15 00:11:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 336 bytes |
| コンパイル時間 | 1,640 ms |
| コンパイル使用メモリ | 177,188 KB |
| 実行使用メモリ | 13,040 KB |
| 最終ジャッジ日時 | 2024-06-27 20:09:07 |
| 合計ジャッジ時間 | 2,756 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 WA * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
string S;
cin >> S;
int ans = 0, sum = 0;
map<int,int> mp;
mp[-1] = 0;
for (int i = 0; i < S.size(); i++)
{
sum += S[i] == 'A' ? 1 : -1;
if (mp.count(sum)) ans = max(ans, i - mp[sum]);
else mp[sum] = i;
}
printf("%d\n", ans);
return 0;
}