結果

問題 No.1433 Two color sequence
ユーザー miscalcmiscalc
提出日時 2021-03-19 22:06:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 168,128 KB
実行使用メモリ 6,900 KB
最終ジャッジ日時 2023-08-12 02:20:40
合計ジャッジ時間 4,681 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 35 ms
6,632 KB
testcase_04 AC 35 ms
6,648 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 88 ms
6,860 KB
testcase_09 AC 86 ms
6,720 KB
testcase_10 AC 83 ms
6,380 KB
testcase_11 AC 83 ms
6,388 KB
testcase_12 AC 86 ms
6,576 KB
testcase_13 AC 86 ms
6,652 KB
testcase_14 AC 86 ms
6,584 KB
testcase_15 AC 86 ms
6,588 KB
testcase_16 AC 86 ms
6,592 KB
testcase_17 AC 86 ms
6,640 KB
testcase_18 AC 86 ms
6,720 KB
testcase_19 AC 86 ms
6,728 KB
testcase_20 AC 87 ms
6,592 KB
testcase_21 AC 86 ms
6,720 KB
testcase_22 AC 86 ms
6,900 KB
testcase_23 AC 86 ms
6,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
//constexpr ll MOD = 1e9 + 7;
constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  vector<ll> acA(N + 1, 0);
  for (ll i = 0; i < N; i++)
  {
    acA.at(i + 1) = acA.at(i) + ((S.at(i) == 'R') ? 1 : -1) * A.at(i);
  }

  ll M = *max_element(acA.begin(), acA.end());
  ll m = *min_element(acA.begin(), acA.end());
  ll ans = M - m;

  cout << ans << endl;
}
0