#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=2e5+10;
ll n,a[N],col[N];
ll dp[2][2];
int main() {
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n;
for (int i=1; i<=n; ++i) cin>>a[i];
for (int i=1; i<=n; ++i) {
char x;
cin>>x;
col[i]=(x=='R'?1:0);
}
for (int i=1; i<=n; ++i){
int x=a[i]&1;//奇偶性
int y=col[i];//颜色性
dp[x][y]=max(dp[x][y],dp[!x][!y]+a[i]);
}
cout<<max(dp[0][0],max(dp[0][1],max(dp[1][0],dp[1][1])));
return 0;
}
牛客练习赛100B题;
于 2022-06-11 15:38:11 首次发布



575

被折叠的 条评论
为什么被折叠?



