题解 CF387B 【George and Round】

题目大家都理解清楚了吧

其实就是尽量多用已有的题,就要求对自己的题按复杂度由低到高排序,从头到尾遍历,用贪心。排序为了便于比较。然后就是只要普通的遍历枚举就可以辣~

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cctype>
#include <vector>
#include <queue>
#include <stack>//头文件(管理都不用万能我为神马要用万能)
using namespace std;
int n,m,a[1000005],b[1000005],l,r;//不要被这个空间吓着了,放心,不会炸
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
    return x*f;
}//快读(cz专用模板)
int main(){
    n=read(),m=read();
    for(int i=0;i<n;i++)
        a[i]=read();
    for(int i=0;i<m;i++)
        b[i]=read();//输入部分就不详细讲了
    sort(a,a+n);
    sort(b,b+m);//排序,以便后头进行比较分析
    while(l<n&&r<m){//遍历枚举
        if(a[l]<=b[r])
            l++; 
        r++;
    }
    cout<<n-l<<endl;//最后输出掉
    return 0;
}
 

猜你喜欢

转载自www.cnblogs.com/Sworddust/p/11615280.html