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&&A[N]<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)