結果

問題 No.1433 Two color sequence
ユーザー shu8Creamshu8Cream
提出日時 2021-03-20 10:43:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 1,825 ms
コンパイル使用メモリ 204,628 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 21:39:34
合計ジャッジ時間 3,890 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 14 ms
6,944 KB
testcase_04 AC 14 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 26 ms
6,944 KB
testcase_09 AC 26 ms
6,940 KB
testcase_10 AC 25 ms
6,944 KB
testcase_11 AC 25 ms
6,940 KB
testcase_12 AC 26 ms
6,944 KB
testcase_13 AC 28 ms
6,940 KB
testcase_14 AC 27 ms
6,944 KB
testcase_15 AC 25 ms
6,940 KB
testcase_16 AC 26 ms
6,944 KB
testcase_17 AC 26 ms
6,944 KB
testcase_18 AC 27 ms
6,940 KB
testcase_19 AC 26 ms
6,940 KB
testcase_20 AC 26 ms
6,940 KB
testcase_21 AC 28 ms
6,940 KB
testcase_22 AC 27 ms
6,940 KB
testcase_23 AC 26 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
*    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;
}
0