結果
| 問題 |
No.1433 Two color sequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-19 21:52:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 92 ms / 2,000 ms |
| コード長 | 410 bytes |
| コンパイル時間 | 1,527 ms |
| コンパイル使用メモリ | 165,712 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-18 21:59:57 |
| 合計ジャッジ時間 | 4,204 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main() {
int N;
string S;
cin >> N >> S;
ll a, asum = 0, mins = 0, maxs = 0;
rep(i, N) {
cin >> a;
if (S[i] == 'B') a = -a;
asum += a;
mins = min(mins, asum);
maxs = max(maxs, asum);
}
cout << maxs - mins << "\n";
}