結果
問題 |
No.1433 Two color sequence
|
ユーザー |
|
提出日時 | 2021-03-20 10:43:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 669 bytes |
コンパイル時間 | 2,721 ms |
コンパイル使用メモリ | 194,520 KB |
最終ジャッジ日時 | 2025-01-19 20:10:06 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
/** * author: shu8Cream * created: 19.03.2021 23:17:00 **/ #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair<int,int>; using vi = vector<int>; using vvi = vector<vi>; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; string s; cin >> n >> s; vector<ll> a(n),ra(n+1); rep(i,n) cin >> a[i]; ll ans = 0; rep(i,n) if(s[i]=='B') a[i] = -a[i]; rep(i,n) ra[i+1]=ra[i]+a[i]; ll m=1e18, M=-1e18; rep(i,n+1){ m=min(m,ra[i]); M=max(M,ra[i]); } cout << abs(M-m) << endl; }