Idea: First the wellhead is processed into an ascending sequence, and then two points are inserted in each plate position.
1#include <iostream>2#include <queue>3#include <stack>4#include <cstdio>5#include <vector>6#include <map>7#include <Set>8#include <bitset>9#include <algorithm>Ten#include <cmath> One#include <cstring> A#include <cstdlib> -#include <string> -#include <sstream> the#include <time.h> - #defineX First - #defineY Second - #definePB Push_back + #defineMP Make_pair - #defineLson l,m,rt*2 + #defineRson m+1,r,rt*2+1 A #defineMT (A, b) memset (a,b,sizeof (A)) at #defineMoD 1000000007 - using namespacestd; -typedefLong LongLL; - Const DoublePI = ACOs (-1); - Const intn=1e5+Ten; - Const intINF =0x3f3f3f3f; in ConstLL inf=0x3f3f3f3f3f3f3f3fll; - intW[n],d[n]; to intMain () + { - #ifdef Local theFreopen ("Data.txt","R", stdin); * #endif $ intn,m,ans=0;Panax NotoginsengCin>>n>>m; - for(intI=0; i<n;i++) cin>>W[i]; the for(intI=0; i<m;i++) cin>>D[i]; + for(intI=1; i<n;i++) A { the if(w[i]>w[i-1]) w[i]=w[i-1]; + } -Sort (w,w+n); $w[n]=inf; $ for(intI=0, k=0; i<m;i++) - { -K=lower_bound (w+k,w+n+1, D[i])-w+1; the if(k>n) Break; -ans++;Wuyi } thecout<<ans<<Endl; - #ifdef Local WuCerr <<"Time :"<< (LL) clock () * +/Clocks_per_sec <<"Ms"<<Endl; - #endif About}
View Code
1279 Throwing dishes