結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
focus
|
| 提出日時 | 2018-05-21 22:57:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 439 bytes |
| コンパイル時間 | 578 ms |
| コンパイル使用メモリ | 71,680 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-06-28 15:38:30 |
| 合計ジャッジ時間 | 4,121 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 1 -- * 9 |
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
using ll = long long ;
using namespace std;
int main(){
string str;
ll ans=0;
cin >> str;
ll len = str.size();
vector<ll> sum(len+1);
sum[0] = 0;
for(ll i=0;i<len;i++){
if(str[i]=='A') sum[i+1]=sum[i]+1;
else sum[i+1]=sum[i]-1;
}
for(ll i=0;i<len+1;i++){
for(ll j=i+ans;j<len+1;j++){
if(sum[j]==sum[i]) ans = max(j-i,ans);
}
}
cout << ans << endl;
return 0;
}
focus