HDU1257最少拦截系统
2014-10-28 15:01
232 查看
/*求有多少个降序子序列*/
/*
看到一个算法比我精简的
*/
#include<iostream> using namespace std; int main() { int n; int a[1000]; while (cin >> n) { if (n == 0) { cout << 1 << endl; continue; } for (int i = 0; i < n; ++i) { cin >> a[i]; } int tem = 0, min = a[0]; there: for (int i = 1; i < n; ++i) { if (a[i] != 0 && a[i] < min) { min = a[i]; a[i] = 0; } if (i == n - 1) { tem++; for (int t = 1; t < n; ++t) { if (a[t] != 0) { min = a[t]; a[t] = 0; //赋值后使其等于零 goto there; } } } } cout << tem << endl; } return 0; }
/*
看到一个算法比我精简的
#include<stdio.h> #include<string.h> int main() { int i,n,count,a[1005],res,max; while (scanf("%d",&n)!=EOF) { for (i=1; i<=n; ++i) { scanf("%d",&a[i]); } res=0; count=n; while (count) { max=50000; res++; for (i=1; i<=n; ++i) { if (a[i]>0 && a[i]<max) { max=a[i]; a[i]=-1; count--; } } } printf("%d/n",res); } return 0; }
*/
相关文章推荐
- hdu1257 最少拦截系统
- HDU1257--最少拦截系统
- HDU1257:最少拦截系统
- HDU1257最少拦截系统
- HDU1257:最少拦截系统(LIS)
- hdu1257 最少拦截系统
- HDU1257 最少拦截系统
- hdu1257最少拦截系统
- HDU1257最少拦截系统
- hdu1257最少拦截系统
- HDU1257最少拦截系统
- hdu1257 最少拦截系统 (贪心)
- hdu1257 最少拦截系统 ——DP么?
- HDU1257 最少拦截系统
- hdu1257: 最少拦截系统
- HDU1257:最少拦截系统
- hdu1257最少拦截系统【贪心算法】
- hdu1257(最少拦截系统 )
- hdu1257 最少拦截系统 (贪心)
- HDU1257:最少拦截系统(LIS)