結果
| 問題 |
No.3210 Fixed Sign Sequense
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-25 21:52:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,756 bytes |
| コンパイル時間 | 2,162 ms |
| コンパイル使用メモリ | 196,472 KB |
| 実行使用メモリ | 8,404 KB |
| 最終ジャッジ日時 | 2025-07-25 21:52:24 |
| 合計ジャッジ時間 | 2,875 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define mod99 998244353
#define mod107 1000000007
#define endl "\n"
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define prep(i,a,n) for (ll i = a; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define si(x) ((ll)(x).size())
#define YN(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yn(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define PRE(x) cout << fixed << setprecision(x)
#define yes cout << "Yes\n"
#define no cout << "No\n"
//#define YES cout << "YES\n"
//#define NO cout << "NO\n"
template <typename T> inline T gcd(T a,T b) {return (b==0)?a:gcd(b,a%b);}
template <typename T> inline T lcm(T a, T b) {return a/gcd(a,b)*b;}
#define sq(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
const ld PI=3.141592653589793238462643383279;
const ll INF=1000000000000000000LL;
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string abc = "abcdefghijklmnopqrstuvwxyz";
#define next_p next_permutation
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
bool isprime(ll N){
if(N<2) return false;
for(ll i=2; i*i<=N; i++) if(N%i==0) return false;
return true;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n;cin >> n;
string s;cin >> s;
vector<ll> m(n),p(n);
ll ma=0,pl=0;
rep(i,n) {
if(s[i]=='-') ma++;
m[i]=ma;
}
for(ll i=n-1;i>=0;i--) {
if(s[i]=='+') pl++;
p[i]=pl;
}
ll ans=0;
rep(i,n-1) ans=max(ans,m[i]+p[i+1]);
rep(i,n-2) if(s[i+1]=='0') ans=max(ans,m[i]+1+p[i+1]);
cout << ans << endl;
}