結果

問題 No.1433 Two color sequence
ユーザー hamigakiko0721hamigakiko0721
提出日時 2022-01-31 14:59:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 852 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 168,360 KB
実行使用メモリ 11,732 KB
最終ジャッジ日時 2023-09-02 02:10:08
合計ジャッジ時間 7,328 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
using LL = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); ++i)
template<class T>void chmin(T&a, T b){if(a > b) a = b;}
template<class T>void chmax(T&a, T b){if(a < b) a = b;}


int main(){
	int N; cin >> N;
	string S; cin >> S;
	vector<int> a(N, 0);
	for(int i = 0; i < N; ++i) cin >> a[i];
	vector<LL> R(N+1, 0), B(N+1, 0);
	for(int i = 0; i < N; ++i){
		R[i+1] += R[i];
		B[i+1] += B[i];
		if(S[i] == 'R') R[i+1] += a[i];
		else B[i+1] += a[i];
	}

	LL ans = 0;
	for(int i = 1; i <= N; ++i){
		for(int j = 0; j < N; ++j){
			LL tmp = abs(R[i] - R[j] - B[i] + B[j]);
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;
}



0