結果
問題 |
No.672 最長AB列
|
ユーザー |
![]() |
提出日時 | 2018-06-07 13:19:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 515 bytes |
コンパイル時間 | 1,752 ms |
コンパイル使用メモリ | 168,276 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 10:28:07 |
合計ジャッジ時間 | 2,391 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); int puni[2 * n + 1]; fill(puni, puni + 2 * n + 1, -1); puni[n] = 0; int ans = 0; for (int i = 0, j = 0; i < n; i++) { if (s[i] == 'A') { j++; } else { j--; } if (0 <= puni[n + j]) { ans = max(ans, i - puni[n + j]); } else { puni[n + j] = i; } } cout << ans << endl; return 0; }