結果

問題 No.3210 Fixed Sign Sequense
ユーザー tkykwtnb
提出日時 2025-07-25 21:52:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 625 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 82,652 KB
実行使用メモリ 153,672 KB
最終ジャッジ日時 2025-07-25 21:52:55
合計ジャッジ時間 6,010 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=list(input())
m_sm=[0]
z_sm=[0]
p_sm=[0]
for s in S:
    if s=="-":
        m_sm.append(m_sm[-1]+1)
        z_sm.append(z_sm[-1])
        p_sm.append(p_sm[-1])
    elif s=="0":
        m_sm.append(m_sm[-1])
        z_sm.append(z_sm[-1]+1)
        p_sm.append(p_sm[-1])
    else:
        m_sm.append(m_sm[-1])
        z_sm.append(z_sm[-1])
        p_sm.append(p_sm[-1]+1)
ans=0
for i,s in enumerate(S[:-1],1):
    if s=="-":
        ans=max(ans,m_sm[i]+p_sm[-1]-p_sm[i])
    elif s=="0":
        ans=max(ans,m_sm[i-1]+1+p_sm[-1]-p_sm[i])
    else:
        ans=max(ans,m_sm[i-1]+p_sm[-1]-p_sm[i-1])
print(ans)
0