Minimum interception systemTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total Submission (s): 18249 Accepted Submission (s): 7203
Problem description A missile interception system developed by a country to defend its enemy missiles. However, the missile interception system has a flaw: although its first artillery shells can reach a random height, each projectile cannot exceed the height of the previous one. Someday, The radar captures the enemy's missiles. Because the system is still in trial, there is only one system, so it may not be possible to intercept all the missiles.
What do we do? How many systems do you have? You say it's easy, cost? Cost is a big problem. So I came here to help, please calculate the minimum number of interception system required.
Input enters several sets of data. Each group of data contains: Total number of missiles (positive integers), the height at which missiles fly (radar-given height data is a positive integer not greater than 30000, separated by a space)
Output each set of data outputs the minimum number of missile interception systems to be equipped to intercept all missiles.
Sample Input
8 389 207 155 300 299 170 158 65
Sample Output
2
Water
#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;}
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
HDU1257 minimum interception system "greed"