結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
|
提出日時 | 2025-07-25 21:59:09 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 117 ms / 2,000 ms |
コード長 | 379 bytes |
コンパイル時間 | 476 ms |
コンパイル使用メモリ | 82,640 KB |
実行使用メモリ | 107,372 KB |
最終ジャッジ日時 | 2025-07-25 21:59:26 |
合計ジャッジ時間 | 5,101 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import sys input = sys.stdin.readline N = int(input()) S = input().strip() M = [0] P = [0] for s in S: P.append(P[-1]) M.append(M[-1]) if s=="+": P[-1]+=1 elif s=="-": M[-1]+=1 ans = 0 for i in range(N+1): if i<N and S[i]=="0": tmp = M[i] + 1 + P[-1]-P[i] else: tmp = M[i] + P[-1]-P[i] ans = max(ans, tmp) print(ans)