URAL1410. Crack
dp水题 题意读了好一会 是不能连续读两个及以上单词
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stdlib.h> 6 #include<vector> 7 #include<queue> 8 #include<cmath> 9 using namespace std; 10 #define N 10010 11 int dp[N],len[N]; 12 char s[N][30],ss[N*100]; 13 int main() 14 { 15 int i,g=0; 16 while(scanf("%c",&ss[g])!=EOF) 17 { 18 g++; 19 } 20 int t = 0,o=1; 21 for(i = 0 ; i < g ; i++) 22 { 23 if((ss[i]>='a'&&ss[i]<='z')||(ss[i]>='A'&&ss[i]<='Z')) 24 { 25 s[o][t++] = ss[i]; 26 } 27 else 28 { 29 if(t) 30 { 31 s[o][t] = '\0'; 32 len[o] = t; 33 t = 0;o++; 34 } 35 } 36 } 37 if(t) 38 { 39 s[o][t] = '\0'; 40 len[o] = t; 41 t = 0;o++; 42 } 43 for(i = 1 ; i < o ; i++) 44 { 45 dp[i] = max(dp[i-1],dp[i-2]+len[i]); 46 } 47 cout<<dp[o-1]<<endl; 48 return 0; 49 }