結果
問題 | No.672 最長AB列 |
ユーザー | sggkshio |
提出日時 | 2019-10-03 07:47:45 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 702 bytes |
コンパイル時間 | 821 ms |
コンパイル使用メモリ | 95,052 KB |
実行使用メモリ | 24,448 KB |
最終ジャッジ日時 | 2024-04-14 09:03:48 |
合計ジャッジ時間 | 4,886 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
24,192 KB |
testcase_01 | AC | 128 ms
24,320 KB |
testcase_02 | AC | 125 ms
24,192 KB |
testcase_03 | AC | 125 ms
24,192 KB |
testcase_04 | WA | - |
testcase_05 | AC | 127 ms
24,320 KB |
testcase_06 | AC | 127 ms
24,320 KB |
testcase_07 | AC | 127 ms
24,320 KB |
testcase_08 | AC | 127 ms
24,320 KB |
testcase_09 | AC | 193 ms
24,448 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 166 ms
24,320 KB |
testcase_14 | WA | - |
testcase_15 | AC | 166 ms
24,320 KB |
testcase_16 | AC | 166 ms
24,320 KB |
testcase_17 | AC | 187 ms
24,448 KB |
testcase_18 | WA | - |
ソースコード
#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 (t[a] == -1)t[a] = i; else { ans = max(ans, i - t[a]); } } cout << ans << endl; return 0; }