結果
問題 | No.1433 Two color sequence |
ユーザー |
![]() |
提出日時 | 2021-03-19 21:56:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 1,618 bytes |
コンパイル時間 | 2,034 ms |
コンパイル使用メモリ | 197,404 KB |
最終ジャッジ日時 | 2025-01-19 18:27:32 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#pragma GCC diagnostic warning "-Wextra"#pragma GCC diagnostic warning "-Wshadow"#include <bits/stdc++.h>using namespace std;template <class A, class B> bool cmin(A& a, B b) { return a > b && (a = b, true); }template <class A, class B> bool cmax(A& a, B b) { return a < b && (a = b, true); }template <class A, class B> ostream& operator<<(ostream& os, pair<A, B>& p) { return os << '(' << p.first << ", " << p.second << ')'; }static bool debug = false;void dump() {}template <class A, class... B> void dump(A&& a, B&&... b) { if (debug) cout << a << (sizeof...(b) ? ' ' : '\n'), dump(b...); }template <class A> void dump1D(A& a) { if (debug) for (auto i = a.begin(); i != a.end(); i++) cout << *i << (next(i) != a.end() ? ' ' : '\n'); }template <class A> void dump2D(A& a) { if (debug) for (auto i = a.begin(); i != a.end(); i++) dump1D(*i), cout << (next(i) != a.end() ? "" : "\n"); }signed main() {cin.tie(nullptr)->sync_with_stdio(false);// debug = true;long N;string S;cin >> N >> S;vector<long> A(N);for (long i = 0; i < N; i++) cin >> A.at(i);vector<long> R(N), B(N);for (long i = 0; i < N; i++) {if (S.at(i) == 'R') R.at(i) = A.at(i);else B.at(i) = A.at(i);}dump1D(R);dump1D(B);auto cs = [](auto vec) {vector<long> ret((long)vec.size() + 1);partial_sum(vec.begin(), vec.end(), ret.begin() + 1);return ret;};R = cs(R);B = cs(B);dump1D(R);dump1D(B);for (long i = 0; i < N + 1; i++) {R.at(i) -= B.at(i);}dump1D(R);cout << *max_element(R.begin(), R.end()) - *min_element(R.begin(), R.end()) << '\n';}