HDU1257 minimum interception system "greed"

Source: Internet
Author: User
Tags radar

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.