[2016-03-27] [HDU] [1257] [Minimum interception system]

Source: Internet
Author: User

    • Time: 2016-03-27-14:51:35 Sunday
    • Title Number: [2016-03-27][hdu][1257][minimum interception system]
    • Analysis: greedy, whenever unable to intercept the addition of an interception system, you can find that each interception system interception of the height of the comparison and the order of occurrence. That the second system is always higher than the first one.
  
 
  1. #include <cstdio>
  2. using namespace std;
  3. int a[30000 + 10];
  4. int main(){
  5. int n,b,flg;
  6. while(~scanf("%d",&n)){
  7. int cur = 1 a [ 0 ] = 30000 Span class= "PLN" > + 10
  8. for(int i = 0;i < n ; ++i){
  9. scanf("%d",&b);
  10. flg = 1;
  11. for(int j = 0;j < cur;++j){
  12. if(a[j] >= b){
  13. a[j] = b;
  14. flg = 0;
  15. break;
  16. }
  17. }
  18. if(flg){
  19. a[cur] = b;
  20. ++cur;
  21. }
  22. }
  23. printf("%d\n",cur);
  24. }
  25. return 0;
  26. }


From for notes (Wiz)

[2016-03-27] [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.