标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 41189 Accepted Submission(s): 14108
1 #include<iostream> 2 #include<string> 3 #include<cstdio> 4 #include<cmath> 5 #include<cstring> 6 #include<algorithm> 7 #include<vector> 8 #include<iomanip> 9 #include<queue> 10 using namespace std; 11 int f[11][100001]; 12 int max(int a,int b,int c) 13 { 14 return a>b?(a>c?a:c):(b>c?b:c); 15 } 16 int main() 17 { 18 int n,x,t; 19 while(scanf("%d",&n)) 20 { 21 if(n==0) break; 22 memset(f,0,sizeof(f)); 23 int maxt=0; 24 while(n--) 25 { 26 scanf("%d%d",&x,&t); 27 f[x][t]++; 28 if(t>maxt) maxt=t; 29 } 30 for(int i=maxt-1;i>=0;i--) 31 { 32 f[0][i]+=max(f[0][i+1],f[1][i+1],0); 33 f[10][i]+=max(f[10][i+1],f[9][i+1],0); 34 for(int j=1;j<=9;j++) 35 { 36 f[j][i]+=max(f[j][i+1],f[j-1][i+1],f[j+1][i+1]); 37 } 38 } 39 printf("%d\n",f[5][0]); 40 } 41 return 0; 42 }
标签:
原文地址:http://www.cnblogs.com/--ZHIYUAN/p/5719880.html