結果
| 問題 |
No.1433 Two color sequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-31 14:59:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 852 bytes |
| コンパイル時間 | 1,715 ms |
| コンパイル使用メモリ | 169,932 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2024-06-11 08:49:03 |
| 合計ジャッジ時間 | 6,366 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 20 |
ソースコード
#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;
}