Match for Bonus
描述
Roy played a game with his roommates the other day.
His roommates wrote 2 strings of characters, and gave each character a bonus value. When Roy pinned the positions of one common character in the 2 strings, the bonus value of that character would be added to Roy's score. However at the mean time, the 2 characters and those before them in the strings would be erased.
Roy now needs your help, because he wants to know the maximum score he can get.
输入
There are several test cases.
For each test case, the first line contains an integer N.
The following N lines describe a list of N characters and their bonus values.
Then the following 2 lines give the 2 strings, each string contains no more than 10000 characters.
输出
For each test case, output in one line the best score Roy can get.
样例输入
3
a 1
b 1
c 1
abc
bca
3
a 1
b 10
c 100
abc
cab
样例输出
2
100
题意: 如果有相同的字符, 这权值p + 相应的权值, 但是如果匹配时, 在当前字符前面的字符会全部
题意:
代码:
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 10005
char str1[MAX], str2[MAX];
int val[MAX];
int n;
{
}
{
//
}