結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
36_bocky
|
| 提出日時 | 2018-04-13 23:32:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 604 bytes |
| コンパイル時間 | 1,454 ms |
| コンパイル使用メモリ | 68,964 KB |
| 実行使用メモリ | 17,724 KB |
| 最終ジャッジ日時 | 2024-06-27 19:49:41 |
| 合計ジャッジ時間 | 2,176 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 6 |
ソースコード
#include <iostream>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<long long , long long>p;
int main()
{
long long rui[200001];
map<long long, long long> mp;
string str;
long long ans = 0;
cin >> str;
for ( long long i = 0; i < str.size(); i++) {
if (str[i] == 'A' ) {
rui[i + 1] = rui[i] + 1;
} else {
rui[i + 1] = rui[i] - 1;
}
if ( mp.count(rui[i + 1]) == 0 ) {
mp[rui[i + 1]] = i + 1;
} else {
ans = max(ans, i + 1 - mp[rui[i + 1]] );
}
}
printf("%lld\n", ans);
return (0);
}
36_bocky