結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
gt_ham_bass
|
| 提出日時 | 2018-04-14 12:04:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 399 bytes |
| コンパイル時間 | 3,022 ms |
| コンパイル使用メモリ | 158,164 KB |
| 実行使用メモリ | 11,292 KB |
| 最終ジャッジ日時 | 2024-06-27 20:06:36 |
| 合計ジャッジ時間 | 4,847 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 1 TLE * 1 -- * 9 |
ソースコード
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int c,n,ans,p[210000];
int main(){
string s;
cin >> s;
n = s.size();
for(int i = 0; i < n; i++){
if(s[i] == 'A'){
c++;
p[i] = c;
}
else if(s[i] == 'B'){
c--;
p[i] = c;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; i+j < n; j++){
if(p[i] == p[i+j]) ans = max(ans,j);
}
}
cout << ans << endl;
}
gt_ham_bass