結果
問題 | No.672 最長AB列 |
ユーザー |
|
提出日時 | 2019-10-03 07:53:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 192 ms / 2,000 ms |
コード長 | 732 bytes |
コンパイル時間 | 747 ms |
コンパイル使用メモリ | 92,932 KB |
実行使用メモリ | 24,448 KB |
最終ジャッジ日時 | 2024-10-03 06:06:30 |
合計ジャッジ時間 | 4,476 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#define _USE_MATH_DEFINES#include <cmath>#include <cstdio>#include <vector>#include <iostream>#include <algorithm>#include <string>#include<math.h>#include<iomanip>#include<stdio.h>#include <stdlib.h>#include<stdio.h>#include <queue>#include<map>#include <sstream>#include<set>#include<stack>//#include<bits/stdc++.h>using namespace std;int main() {string p;cin >> p;int ans = 0;map<int, int>t;for (int i = -222222; i <= 222222; i++) {t[i] = -1;}// t[0] = 0;int a = 0;for (int i = 0; i < p.size(); i++) {if (p[i] == 'A')a++;else a--;if (a&&t[a] == -1)t[a] = i;else {ans = max(ans, i - t[a]);}// cout << ans << endl;}cout << ans << endl;return 0;}