結果
| 問題 |
No.2276 I Want AC
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-04-22 01:46:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 757 bytes |
| コンパイル時間 | 737 ms |
| コンパイル使用メモリ | 105,372 KB |
| 最終ジャッジ日時 | 2025-02-12 12:49:04 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
using ll = long long;
int main(){
ll N, ans=0, cntc=0, now=0, cnta=0;
string S;
cin >> N >> S;
for (int i=0; i<N; i++){
if (S[i] == 'C') ans += cnta;
else cnta++;
}
now = ans;
for (int i=N-1; i>=0; i--){
if (S[i] == 'C') cntc++;
else if (S[i] == '?'){
now -= cntc;
cntc++;
cnta--;
now += cnta;
}
else cnta--;
ans = max(ans, now);
}
cout << ans << endl;
return 0;
}
srjywrdnprkt