結果
問題 |
No.2276 I Want AC
|
ユーザー |
![]() |
提出日時 | 2023-08-29 08:48:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 801 bytes |
コンパイル時間 | 4,233 ms |
コンパイル使用メモリ | 249,816 KB |
最終ジャッジ日時 | 2025-02-16 15:27:08 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 56 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll mod=998244353; ll inf=1009999999999999990; int main(){ ll n; cin >> n; string s; cin >> s; ll a=0; ll c=0; ll ans=0; for (ll i = 0; i < n; i++) { if (s[i]=='A') { a++; }else{ ans+=a; c++; } } ll aa=0; ll now=ans; for (ll i = 0; i < n; i++) { if (s[i]=='?') { c--; now-=aa; now+=c; ans=max(ans,now); aa++; }else if (s[i]=='a') { aa++; }else{ c--; } } cout << ans << endl; }