HDU 1257 Minimum interception system

Source: Internet
Author: User

Http://acm.hdu.edu.cn/showproblem.php?

pid=1257

Main topic:

There is a missile interception system that can only emit shells that are lower than the previous one at a time, given the attack order of some missiles, asking for at least how many missile interceptors are needed to completely stop

Ideas:

Long time no problem. To do the water ~

Direct simulation is possible ~


#include <cstdio>const int maxn = 30000 + 10;const int INF = 0x3ffffff;int A[MAXN], ans;int CUR_MAX[MAXN]; The maximum height the current missile system can reach is int main () {int n;while (~scanf ("%d", &n)) {for (int i = 0; i < n; i++) scanf ("%d", &a[i]); ans = 1 ; Cur_max[0] = a[0];for (int i = 1; i < n; i++) {int dis_min = inf;for (int j = 0; J < ans; J + +) {//When the current missile is smaller than a missile system capable of interception Wait//Find the closest to this missile height if (A[i] < cur_max[j] && dis_min > cur_max[j]) dis_min = j;} if (dis_min = = INF) Dis_min = ans++;cur_max[dis_min] = A[i];} printf ("%d\n", ans);} return 0;}


HDU 1257 Minimum interception system

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.