結果
| 問題 | No.1433 Two color sequence | 
| コンテスト | |
| ユーザー |  merom686 | 
| 提出日時 | 2021-03-19 21:52:55 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 39 ms / 2,000 ms | 
| コード長 | 562 bytes | 
| コンパイル時間 | 866 ms | 
| コンパイル使用メモリ | 96,868 KB | 
| 最終ジャッジ日時 | 2025-01-19 18:25:53 | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n);
    vector<ll> x(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (s[i] == 'B') a[i] *= -1;
        x[i + 1] = x[i] + a[i];
    }
    sort(x.begin(), x.end());
    cout << x.back() - x.front() << endl;
    return 0;
}
            
            
            
        