当前位置 : 主页 > 手机开发 > harmonyos >

HDU 5494(水题)

来源:互联网 收集:自由互联 发布时间:2023-08-28
Card Game Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 207Accepted Submission(s): 157 Problem Description ncards with number a1,a2,...,anwhile Beta has ncards with number b1,b2,...,bn.


Card Game



Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)


Total Submission(s): 207    Accepted Submission(s): 157




Problem Description


n cards with number  a1,a2,...,an while Beta has  n cards with number  b1,b2,...,bn.

First, they choose a number  m no larger than  n. Then they both randomly select  m cards from their own  n


 



Input


T(1≤T≤100), indicating the number of test cases. For each test case:

The first line contains two integer  n and  m  (1≤m≤n≤500). The second line contains  n integers  a1,a2,...,an  (1≤ai≤1000) denoting Soda's cards. The third line contains  n integers  b1,b2,...,bn  (1≤bi≤1000)


 



Output


For each test case, output "YES" (without the quotes) if Soda can always win, otherwise output "NO" (without the quotes) in a single line.


 



Sample Input


2 3 1 4 5 6 1 2 3 5 2 3 4 7 8 9 3 4 5 2 3


 



Sample Output


YES NO


 


#include <stdio.h>
#include <algorithm>
#include <map>
#include <iostream>
#include <string.h>
#include <queue>
using namespace std;
const int maxn=500+10;

int a[maxn];
int b[maxn];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,m;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        scanf("%d%d",&n,&m);
        for(int i=0;i<n;i++)
            scanf("%d",a+i);
        for(int k=0;k<n;k++)
            scanf("%d",b+k);
        sort(a,a+n);
        sort(b,b+n);
        int sum1,sum2;
        sum1=sum2=0;
        for(int i=0;i<m;i++)
            sum1+=a[i];
        for(int k=n-m;k<n;k++)
            sum2+=b[k];
        if(sum1>sum2)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}




上一篇:HDU 5479(栈的应用)
下一篇:没有了
网友评论