coderforce 527A Arrays

题意:给你两个数组。问,在数组A中随便选K个,在数组中随便选M个,问你,是否有可能所选的数中,B中的数都比A中的大。

简单贪心

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long
const LL maxm=1e5+10;
LL a[maxm];
LL b[maxm];
int main()
{
    LL na,nb;
    while(scanf("%lld%lld",&na,&nb)!=EOF)
    {
        LL k,m;
        scanf("%lld%lld",&k,&m);
        for(LL i=0;i<na;i++)
        {
            scanf("%lld",&a[i]);
        }
        for(LL i=0;i<nb;i++)
        {
            scanf("%lld",&b[i]);
        }
        sort(a,a+na);
        sort(b,b+nb);
       if(a[k-1]<b[nb-m])
       {
           printf("YES\n");
       }
       else
       {
           printf("NO\n");
       }

    }
    return 0;
}

你可能感兴趣的:(coderforce 527A Arrays)