1279 Throwing dishes (51nod)

Source: Internet
Author: User

Topic links

http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1279

This question asks how many disks were thrown before when top was sealed = = when Top is blocked even if the lower plate is too small to be thrown down

We use a[] to preserve the width of the well, array b[] to save the size of the plate

First, if the plate J can reach the m, you need to meet min (A[0~i]) >=b[j];

So we just need to save the minimum value to

1#include <stdio.h>2#include <string.h>3#include <iostream>4#include <algorithm>5 #defineMAXN 100006 using namespacestd;7 intA[MAXN],B[MAXN];8 intMain ()9 {Ten     intn,m; Onescanf"%d%d",&n,&m); A      for(intI=0; i<n;i++) -     { -scanf"%d",&a[i]); the     } -      for(intI=0; i<m;i++) -     { -scanf"%d",&b[i]); +     } -     intans=0; +      for(intI=1; i<n;i++) A     { atA[i]=min (a[i-1],a[i]); -     } -      for(intI=0; i<m;i++) -     { -          for(--n;n>=0&AMP;&AMP;A[N]&LT;B[I];--N);//find out the current plate is stuck on the first floor -             if(n>=0) inans++; -             Else to              Break;//jump out of circulation when the plate reaches the wellhead +     } -printf"%d\n", ans); the     return 0; *}

1279 Throwing dishes (51nod)

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.