Anti-Palindromize

题意翻译

### 题目描述 对于一个字串$a$,若其长度$m$为偶数,且对于$\forall i \in[1,m]$,有$a_i \neq a_{m-i+1}$,则将其称为反回文串 Ivan有一个由$n$个小写拉丁字母构成的字串$s$,且$n$为偶数。他想用$s$的一些排列构成一些反回文串$t$。同时他称$i$的美丽值为$b_i$,且字串$t$的美丽值$Ans=\sum_{i=1}^{strlen(s)} b_i[s_i=t_i]$ 请帮Ivan确定$Ans$的最大值 ### 输入输出格式 #### 输入格式: 第一行一个偶数$n(2 \leq n \leq 100)$,表示字串$s$中的字符数量 第二行一个只含小写字母的字串$s$,题目保证存在$s$的一个排列$t$,使得$\forall i \in [1,n],t_i \neq t_{n-i+1}$ 第三行为数组$b(1\leq b_i \leq 100)$ #### 输出格式: 一个整数,$Ans$的最大值

题目描述

A string $ a $ of length $ m $ is called antipalindromic iff $ m $ is even, and for each $ i $ ( $ 1<=i<=m $ ) $ a_{i}≠a_{m-i+1} $ . Ivan has a string $ s $ consisting of $ n $ lowercase Latin letters; $ n $ is even. He wants to form some string $ t $ that will be an antipalindromic permutation of $ s $ . Also Ivan has denoted the beauty of index $ i $ as $ b_{i} $ , and the beauty of $ t $ as the sum of $ b_{i} $ among all indices $ i $ such that $ s_{i}=t_{i} $ . Help Ivan to determine maximum possible beauty of $ t $ he can get.

输入输出格式

输入格式


The first line contains one integer $ n $ ( $ 2<=n<=100 $ , $ n $ is even) — the number of characters in $ s $ . The second line contains the string $ s $ itself. It consists of only lowercase Latin letters, and it is guaranteed that its letters can be reordered to form an antipalindromic string. The third line contains $ n $ integer numbers $ b_{1} $ , $ b_{2} $ , ..., $ b_{n} $ ( $ 1<=b_{i}<=100 $ ), where $ b_{i} $ is the beauty of index $ i $ .

输出格式


Print one number — the maximum possible beauty of $ t $ .

输入输出样例

输入样例 #1

8
abacabac
1 1 1 1 1 1 1 1

输出样例 #1

8

输入样例 #2

8
abaccaba
1 2 3 4 5 6 7 8

输出样例 #2

26

输入样例 #3

8
abacabca
1 2 3 4 4 3 2 1

输出样例 #3

17