标签:des style blog java color 使用
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2850 Accepted Submission(s): 648
1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 using namespace std; 5 6 int dp[2001][2001]; 7 main() 8 { 9 10 char s1[2001], s2[2001], v[26]; 11 int i, j, k; 12 int n, w[26];; 13 while(scanf("%d",&n)==1) 14 { 15 scanf("%s",v); 16 for(i=0;i<n;i++) 17 scanf("%d",&w[v[i]-‘a‘]); 18 scanf("%s%s",s1+1,s2+1); 19 int n1=strlen(s1); 20 int n2=strlen(s2); 21 for(i=0;i<n1;i++) 22 dp[i][0]=0; 23 for(i=0;i<n2;i++) 24 dp[0][i]=0; 25 int MAXH=-1; 26 for(i=1;i<n1;i++) 27 { 28 for(j=1;j<n2;j++) 29 { 30 if(s1[i]==s2[j]) 31 dp[i][j]=dp[i-1][j-1]+w[s2[j]-‘a‘]; 32 else{ 33 dp[i][j]=max(dp[i-1][j],dp[i][j-1]); 34 } 35 MAXH=max(MAXH,dp[i][j]); 36 } 37 } 38 printf("%d\n",MAXH); 39 } 40 }
HDU 1243 最长公共子序列,布布扣,bubuko.com
标签:des style blog java color 使用
原文地址:http://www.cnblogs.com/qq1012662902/p/3836702.html