标签:敏捷 背包 amp print mem 分享 for opened out
http://acm.hdu.edu.cn/showproblem.php?pid=1176
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 66836 Accepted Submission(s): 23470
可转化为类似数塔的模板题
1 #include <cstring> 2 #include <cstdio> 3 #include <cmath> 4 #include <algorithm> 5 #include <iostream> 6 #include <map> 7 typedef long long ll; 8 using namespace std; 9 10 int dp[100005][15]; 11 12 int main(){ 13 int n; 14 while(~scanf("%d",&n)){ 15 if(!n) break; 16 memset(dp,0,sizeof(dp)); 17 int pos,t; 18 int m=-1; 19 for(int i=1;i<=n;i++){ 20 scanf("%d %d",&pos,&t); 21 dp[t][pos]++; 22 m=max(m,t); 23 } 24 for(int i=m-1;i>=0;i--){ 25 dp[i][0]+=max(dp[i+1][0],dp[i+1][1]); 26 dp[i][10]+=max(dp[i+1][10],dp[i+1][9]); 27 for(int j=1;j<=9;j++){ 28 dp[i][j]+=max(dp[i+1][j],max(dp[i+1][j+1],dp[i+1][j-1])); 29 } 30 } 31 printf("%d\n",dp[0][5]); 32 } 33 }
标签:敏捷 背包 amp print mem 分享 for opened out
原文地址:https://www.cnblogs.com/Fighting-sh/p/10075771.html