結果
| 問題 |
No.2276 I Want AC
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-06 21:17:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 65 ms / 2,000 ms |
| コード長 | 655 bytes |
| コンパイル時間 | 354 ms |
| コンパイル使用メモリ | 82,648 KB |
| 実行使用メモリ | 76,100 KB |
| 最終ジャッジ日時 | 2025-10-06 21:17:32 |
| 合計ジャッジ時間 | 5,811 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
ソースコード
## https://yukicoder.me/problems/no/2276
def main():
N = int(input())
S = input()
# 全てAにした時の回答
answer = 0
a_num = 0
for s in S:
if s in ("A", "?"):
a_num += 1
else:
answer += a_num
max_answer = answer
c_num = 0
for s in reversed(S):
if s == "?":
a_num -= 1
answer -= c_num
answer += a_num
c_num += 1
elif s == "C":
c_num += 1
elif s == "A":
a_num -= 1
max_answer = max(max_answer, answer)
print(max_answer)
if __name__ == "__main__":
main()