結果
問題 |
No.3210 Fixed Sign Sequense
|
ユーザー |
|
提出日時 | 2025-08-04 16:15:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 389 bytes |
コンパイル時間 | 2,579 ms |
コンパイル使用メモリ | 276,176 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-08-04 16:15:24 |
合計ジャッジ時間 | 4,967 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll =long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll N; string S; cin>>N>>S; ll p=0,m=0,an=0; for(int i=0;i<N;i++)if(S[i]=='+')p++; for(int i=0;i<N;i++){ if(S[i]=='-')m++; an=max(an,p+m+(S[i]=='0')); if(S[i]=='+')p--; } cout<<an<<"\n"; }