Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 5176 | Accepted: 2028 |
Description
Input
Output
Sample Input
3 3 2 1 1 2 3 5 4 2 2 4 3 3 1 1 5 5 0
Sample Output
2 3 *
Source
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 7 const int maxn=107; 8 int dp[maxn][maxn]; 9 int num[maxn][maxn]; 10 int n; 11 12 int main() 13 { 14 // freopen("in.txt","r",stdin); 15 int a,b; 16 while(~scanf("%d",&n)){ 17 if(n==0){ 18 printf("*\n"); 19 break; 20 } 21 memset(dp,0,sizeof(dp)); 22 memset(num,0,sizeof(num)); 23 for(int i=0;i<n;i++) 24 { 25 scanf("%d%d",&a,&b); 26 num[a][b]++; 27 } 28 for(int i=1;i<=100;i++) 29 for(int j=1;j<=100;j++) 30 { 31 dp[i][j]=max(dp[i-1][j],dp[i][j-1])+num[i][j]; 32 } 33 printf("%d\n",dp[100][100]); 34 } 35 return 0; 36 }
原文:http://www.cnblogs.com/codeyuan/p/4280039.html