- Time: 2016-03-29-09:46:34 Tuesday
- Title Number: [2016-03-29][hdu][1176][free pies]
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxt = 100000 + 10;
int dp[maxt][11];
int a[maxt][11];
int main(){
int n,x,t,maxT;
while (~scanf("%d",&n) && n){
maxT = 0;
memset(a,0,sizeof(a));
for(int i = 0;i < n ; ++i){
scanf("%d%d",&x,&t);
++a[t][x];
if(t > maxT) maxT = t;
}
memset(dp,0,sizeof(dp));
DP[1][4] =a[1][4];DP[1][5] =a[1][5];DP[1][6] =a[1][6];
for(int i = 2;i <= maxT;++i){
for ( int J = 0 ; j < 11 ;++ j Span class= "pun") {
DP [ i ][ j = max ( DP [ i - 1 ][ j DP [ i ][ j );
if ( j - Span class= "lit" >1 >= 0
DP [ i ][ j ] = max ( DP [ i - 1 ][ j - 1 ], DP [ i ][ j
if ( j + Span class= "lit" >1 <= 10
DP [ i ][ j ] = max ( DP [ i - 1 ][ j + 1 ], DP [ i ][ j
dp[i][j] += a[i][j];
}
}
int ans = 0;
for(int i = 0;i < 11;++i){
ans = max(dp[maxT][i],ans);
}
printf("%d\n",ans);
}
return 0;
}
From for notes (Wiz)
[2016-03-29] [HDU] [1176] [Free pies]