結果
問題 | No.1433 Two color sequence |
ユーザー |
|
提出日時 | 2021-03-19 22:17:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 1,164 bytes |
コンパイル時間 | 935 ms |
コンパイル使用メモリ | 95,008 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 22:56:33 |
合計ジャッジ時間 | 3,453 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#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, abs(tot)}); } mn = min(mn, tot); mx = max(mx, tot); } ll res = max(abs(mn - tot), abs(mx - tot)); ans = max({ans, res, abs(tot)}); cout << ans << "\n"; }