HDU 1257 minimum Interception System

Source: Internet
Author: User

HDU 1257 minimum Interception System

 

Question:

There is a missile interception system that can only launch shells lower than the previous one at a time. Given the attack sequence of some missiles, the minimum number of missile interception systems required to completely block them

Ideas:

I haven't done any questions for a long time. Questions ~

Directly simulate it ~

 

 

# Include

 
  
Const int MAXN = 30000 + 10; const int INF = 0x3ffffff; int a [MAXN], ans; int cur_max [MAXN]; // 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 that can be intercepted, // find the 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, ans );} return 0 ;}

 


 

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.