結果
問題 |
No.672 最長AB列
|
ユーザー |
![]() |
提出日時 | 2018-04-21 12:58:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,026 bytes |
コンパイル時間 | 561 ms |
コンパイル使用メモリ | 63,028 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-06-27 20:26:59 |
合計ジャッジ時間 | 2,404 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 RE * 7 |
ソースコード
//#include <bits/stdc++.h> #include<iostream> #include<cstdio> #include<string> #include<algorithm> #include<vector> #include<stack> #include<queue> #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define pb push_back #define INF 93193111451418101 #define MIN -93193111451418101 using namespace std; typedef long long ll;//int64 typedef unsigned long long ull; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; //----------program from here---------- ll a[200030]; ll mx[200030]; ll mn[200030]; ll ans; int main(){ string s; REP(i,200020){ mn[i]=1145141919; } mn[0]=0; cin>>s; REP(i,s.length()){ if(s[i]=='A'){a[i+1]=a[i]+1;} else {a[i+1]=a[i]-1;} } REP(i,s.length()+1){ //cout<<a[i]<<endl; mx[a[i]]=max(i,mx[a[i]]); mn[a[i]]=min(i,mn[a[i]]); } REP(i,s.length()+1){ //cout<<mx[i]<<" "<<mn[i]<<endl; ans=max(mx[i]-mn[i],ans); } cout<<ans<<endl; return 0; }