标签:des style blog http color io os ar java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 26204 Accepted Submission(s): 8930
#include<iostream> #include<cstdio> #include<cstring> using namespace std; #define max(a,b) ((a)>(b)?(a):(b)) //才发现以前写宏写错了、整个人都不好了 #define N 100100 int n; int dp[N][12],mpt[N][12]; //dp[i][j]表示第i秒在坐标j的最大值 int main() { int i,j,maxt; while(scanf("%d",&n) && n) { maxt=-1; memset(mpt,0,sizeof(mpt)); memset(dp,-1000000,sizeof(dp)); for(i=1;i<=n;i++) { int x,t; scanf("%d%d",&x,&t); mpt[t][x]++; maxt=max(maxt,t); } dp[0][5]=0; for(i=1;i<=maxt;i++) { for(j=0;j<11;j++) { dp[i][j]=max(max(dp[i-1][j],dp[i-1][j-1]),dp[i-1][j+1])+mpt[i][j]; } } int ans=0; for(i=0;i<11;i++) { ans=max(ans,dp[maxt][i]); } cout<<ans<<endl; } return 0; }
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/hate13/p/4051686.html