結果

問題 No.1433 Two color sequence
ユーザー US_cubeUS_cube
提出日時 2021-03-19 22:14:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,154 bytes
コンパイル時間 727 ms
コンパイル使用メモリ 94,284 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-29 17:13:10
合計ジャッジ時間 3,315 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 33 ms
5,376 KB
testcase_04 AC 33 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 86 ms
5,376 KB
testcase_09 AC 84 ms
5,376 KB
testcase_10 AC 80 ms
5,376 KB
testcase_11 AC 78 ms
5,376 KB
testcase_12 AC 80 ms
5,376 KB
testcase_13 AC 82 ms
5,376 KB
testcase_14 AC 82 ms
5,376 KB
testcase_15 AC 82 ms
5,376 KB
testcase_16 AC 79 ms
5,376 KB
testcase_17 AC 83 ms
5,376 KB
testcase_18 AC 80 ms
5,376 KB
testcase_19 AC 79 ms
5,376 KB
testcase_20 AC 79 ms
5,376 KB
testcase_21 AC 80 ms
5,376 KB
testcase_22 AC 81 ms
5,376 KB
testcase_23 AC 82 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <climits>

#define rep(i, n) for(int i = 0; i < n; i++)
#define per(i, n) for(int i = n - 1; i >= 0; i--)
using ll = long long;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define mod 1000000007
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  ll mn = 1e18, mx = -1e18;
  ll tot = 0, ans = -1e18;
  rep(i, n){
    int a; cin >> a;
    if(s[i] == 'R') tot += a;
    else tot -= a;
    if(i){
      ll res = max(abs(mn - tot), abs(mx - tot));
      ans = max({ans, res, tot});
    }
    mn = min(mn, tot);
    mx = max(mx, tot);
  }
  ll res = max(abs(mn - tot), abs(mx - tot));
  ans = max({ans, res, tot});
  cout << ans << "\n";
}
0