8 389 207 155 300 299 170 158 65
2
#include <stdio.h> #include <vector> using std::vector; int main() { int n, i, a, t, j, ans; vector<int> vec; vector<bool> vis; while(scanf("%d", &n) == 1){ vec.clear(); vis.clear(); for(i = 0; i < n; ++i){ scanf("%d", &a); vec.push_back(a); vis.push_back(false); } for(i = ans = 0; i < n; ++i){ if(vis[i]) continue; a = vec[i]; ++ans; for(j = i + 1; j < n; ++j){ if(vis[j]) continue; if(a >= vec[j]){ vis[j] = 1; a = vec[j]; } } } printf("%d\n", ans); } return 0; }
HDU1257 最少拦截系统 【贪心】,布布扣,bubuko.com
原文:http://blog.csdn.net/chang_mu/article/details/38382973