解题思路:





注意事项:





参考代码:

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,i,j,a[1024],b[1024],x,count;
    while((cin>>n)&&n)
    {
        count=0;
        for(i=0;i<n;i++)
        {
            cin>>x;
            a[i]=x;
        }
        for(j=0;j<n;j++)
        {
            cin>>x;
            b[j]=x;
        }
        sort(a,a+n);
        sort(b,b+n);
        i=0;
        for(j=0;j<n;)
        {
            if(a[i]>b[j])
            {
                count++;
                i++;
                j++;
            }
            else
                i++;
            if(i>=n)
                break;
        }
        if(count>n/2)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


 

0.0分

1 人评分

  评论区