結果
問題 |
No.672 最長AB列
|
ユーザー |
|
提出日時 | 2018-04-14 02:57:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 269 bytes |
コンパイル時間 | 743 ms |
コンパイル使用メモリ | 78,060 KB |
実行使用メモリ | 13,040 KB |
最終ジャッジ日時 | 2024-06-27 20:05:07 |
合計ジャッジ時間 | 1,834 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main() | ^~~~
ソースコード
#include<iostream> #include<map> using namespace std; main() { string s;cin>>s; map<int,int>M; int now=0,ans=0;M[0]=1; for(int i=0;i<s.size();i++) { if(s[i]=='A')now++; else now--; if(M[now])ans=max(ans,i-M[now]+2); else M[now]=i+2; } cout<<ans<<endl; }