#include <stdio.h> #include <string.h> int main() { int d[1001], ans[1001]; int n, i, j, flag, rst; while(~scanf("%d", &n) && n) { for(i=0; i<n; i ) scanf("%d", &d[i]); memset(ans, 0, sizeof(ans)); for(i=0; i<n; i ) { flag = 0; int temp = -1;//记录最大值 for(j=0; j<i; j ) if(d[i]>d[j] && temp<ans[j]) { temp = ans[j]; flag = 1; }// end if if(flag) ans[i] = temp d[i]; else ans[i] = d[i]; }//end for rst = -1; for(i=0; i<n; i ) if(rst<ans[i]) rst = ans[i]; printf("%dn", rst); }//end while return 0; }
hdu1087
2018-06-04 11:26:53
浏览数 (1)