标签:
3 2 0 0 2 2 2 3 2 0 0 2 2 2
2 2
1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 510; 4 int dp[maxn],cnt[maxn][maxn],n; 5 int main(){ 6 int u,v; 7 while(~scanf("%d",&n)){ 8 memset(dp,0,sizeof dp); 9 memset(cnt,0,sizeof cnt); 10 for(int i = 0; i < n; ++i){ 11 scanf("%d%d",&u,&v); 12 if(u + v < n && cnt[u][v] < (n - u - v)) cnt[u][v]++; 13 } 14 for(int i = 1; i <= n; ++i){ 15 for(int j = 0; j < i; ++j) 16 dp[i] = max(dp[i],dp[j] + cnt[j][n-i]); 17 } 18 printf("%d\n",dp[n]); 19 } 20 return 0; 21 }
标签:
原文地址:http://www.cnblogs.com/crackpotisback/p/4816511.html