結果
| 問題 |
No.1433 Two color sequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-05 05:36:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 90 ms / 2,000 ms |
| コード長 | 490 bytes |
| コンパイル時間 | 1,455 ms |
| コンパイル使用メモリ | 167,884 KB |
| 実行使用メモリ | 6,912 KB |
| 最終ジャッジ日時 | 2024-12-15 05:25:17 |
| 合計ジャッジ時間 | 5,181 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll a[200005];
ll b[200005];
int main(){
int n; cin >> n;
string s; cin >> s;
for(int i = 0; i < n; i++){
ll num; cin >> num;
if(s[i] == 'R') a[i] = num;
else a[i] = -num;
}
b[0] = 0;
for(int i = 0; i < n; i++) b[i+1] = b[i] + a[i];
ll M = -1e18;
ll m = 1e18;
for(int i = 0; i <= n; i++){
M = max(M, b[i]);
m = min(m, b[i]);
}
ll ans = M - m;
cout << ans << endl;
return 0;
}