結果
| 問題 |
No.3210 Fixed Sign Sequense
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-25 22:17:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 789 bytes |
| コンパイル時間 | 1,873 ms |
| コンパイル使用メモリ | 81,908 KB |
| 実行使用メモリ | 110,988 KB |
| 最終ジャッジ日時 | 2025-07-25 22:18:06 |
| 合計ジャッジ時間 | 5,152 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 17 |
ソースコード
n=int(input())
s=input().split("0")
ans=1
p=0
m=0
for i,si in enumerate(s):
if len(si)==0:
ans=max(ans,m+1)
else:
np=0
nm=0
f=[0]
for sii in si:
if sii=="-":
nm+=1
f.append(f[-1]+1)
else:
np+=1
f.append(f[-1])
f=f[1:]
si=si[::-1]
b=[0]
for sii in si:
if sii=="+":
b.append(b[-1]+1)
else:
b.append(b[-1])
b=b[1:]
b.reverse()
for fi,bi in zip(f,b):
ans=max(ans,fi+bi)
if i==0:
ans=max(ans,nm)
ans=max(ans,np)
else:
ans=max(ans,m+np+1)
m=nm
p=np
print(ans)