码迷,mamicode.com
首页 > 其他好文 > 详细

题解 CF387B 【George and Round】

时间:2019-10-01 16:12:46      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:ios   using   str   输入   放心   span   ret   理解   nbsp   

题目大家都理解清楚了吧

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

#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;
}

 

 

题解 CF387B 【George and Round】

标签:ios   using   str   输入   放心   span   ret   理解   nbsp   

原文地址:https://www.cnblogs.com/Sworddust/p/11615280.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!