[HDOJ1261] Minimum interception system

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1257

The DP array records the height at which a set of interception systems can now be intercepted.

Greed can be over, each read into a missile height, and before the lowest comparison, if the missile is higher than before, it is necessary to add a set of interception system, and the height of the missile is recorded. If it is lower than the previous one, then let the most recent set of interception systems higher than it intercept it, and change that set of DP values.

1#include <cstdio>2#include <cstdlib>3#include <cstring>4#include <algorithm>5#include <iostream>6#include <cmath>7#include <queue>8#include <map>9#include <Set>Ten#include <stack> One#include <list> A#include <vector> -  - using namespacestd; the  - Const intMAXN =30010; - intN; - inttmp; + intDP[MAXN]; -  + intMain () { A     //freopen ("in", "R", stdin); at      while(~SCANF ("%d", &N)) { -         intCNT =1; -         intFlag =0; -          while(n--) { -scanf"%d", &tmp); -             if(!flag) { indp[0] =tmp; -Flag =1; to             } +             inti; -              for(i =0; I < CNT; i++) { the                 if(TMP <=Dp[i]) { *Dp[i] =tmp; $                      Break;Panax Notoginseng                 } -             } the             if(i = =CNT) { +dp[cnt++] =tmp; A             } the         } +printf"%d\n", CNT); -     } $}

[HDOJ1261] 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.