hdu 1176(矩陣dp)
阿新 • • 發佈:2017-10-21
con ems nbsp pre %d == print using turn
這是個煞筆題,題目沒告訴我他會每秒移動一米啊,而且,不是說兩端不能站人嗎
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; const int maxn=100000+100; int dp[maxn][15]; int n; int main() { while(~scanf("%d",&n)&&n) { memset(dp,0,sizeof(dp));int x,t; int max_t=0; for(int i=1;i<=n;i++) { scanf("%d%d",&x,&t); dp[t][x]+=1; max_t=max(max_t,t); } for(int i=max_t-1;i>=0;i--) { for(int j=0;j<=10;j++) {if(j==0) dp[i][j]+=max(dp[i+1][j],dp[i+1][j+1]); else dp[i][j]+=max(max(dp[i+1][j-1],dp[i+1][j]),dp[i+1][j+1]); } } printf("%d\n",dp[0][5]); } return 0; }
hdu 1176(矩陣dp)