結果

問題 No.1433 Two color sequence
ユーザー miscalcmiscalc
提出日時 2021-03-19 22:06:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 170,128 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-04-29 17:01:16
合計ジャッジ時間 4,426 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 38 ms
6,656 KB
testcase_04 AC 38 ms
6,656 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 95 ms
6,656 KB
testcase_09 AC 91 ms
6,656 KB
testcase_10 AC 88 ms
6,528 KB
testcase_11 AC 89 ms
6,528 KB
testcase_12 AC 91 ms
6,656 KB
testcase_13 AC 90 ms
6,656 KB
testcase_14 AC 92 ms
6,656 KB
testcase_15 AC 92 ms
6,656 KB
testcase_16 AC 92 ms
6,656 KB
testcase_17 AC 92 ms
6,656 KB
testcase_18 AC 93 ms
6,656 KB
testcase_19 AC 92 ms
6,656 KB
testcase_20 AC 92 ms
6,656 KB
testcase_21 AC 92 ms
6,656 KB
testcase_22 AC 93 ms
6,656 KB
testcase_23 AC 96 ms
6,656 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