标签:
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<cmath> 5 #include<algorithm> 6 #define N 100010 7 using namespace std; 8 int a[N], b[N], ans; 9 int main() 10 { 11 int n; 12 while(~scanf("%d",&n)) 13 { 14 memset(a, 0, sizeof(a)); 15 memset(b, 0, sizeof(b)); 16 ans = 0; 17 for (int i = 0; i < n; i++) 18 { 19 scanf ("%d", &a[i]); 20 for (int j = 0; j <= ans; j++) 21 { 22 if (a[i] < b[j]) 23 { 24 b[j] = a[i]; 25 break; 26 } 27 else if (j == ans) 28 { 29 b[++ans] = a[i]; 30 break; 31 } 32 } 33 sort(b+1, b+ans); 34 } 35 printf("%d\n", ans); 36 } 37 return 0; 38 }
HDU-1257 导弹拦截系统 http://acm.hdu.edu.cn/showproblem.php?pid=1257
标签:
原文地址:http://www.cnblogs.com/Aa948766160/p/5765665.html