HDU 5494 Card Game(排个序就可以了)——BestCoder Round #58(div.2)
来源:互联网 发布:类似伊甸湖的电影知乎 编辑:程序博客网 时间:2024/06/01 10:17
Card Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Problem Description
Soda and Beta are good friends. They are going to play a card game today. Soda has n cards with number a1,a2,...,an while Beta has n cards with number b1,b2,...,bn .
First, they choose a numberm no larger than n . Then they both randomly select m cards from their own n cards. The one with larger sum of the selected cards will win. Soda wants to know if he can always win no mater what cards will be randomly selected from him and Beta.
First, they choose a number
Input
There are multiple test cases. The first line of input contains an integer T(1≤T≤100) , indicating the number of test cases. For each test case:
The first line contains two integern 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) denoting Beta's cards.
The first line contains two integer
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
23 14 5 61 2 35 23 4 7 8 93 4 5 2 3
Sample Output
YESNO
Source
BestCoder Round #58 (div.2)
/************************************************************************/
附上该题对应的中文题
Card Game
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
问题描述
Soda和Beta是好朋友. 今天他们准备要玩一个游戏. Soda有n张牌, 牌面上数字分别为a1,a2,...,an. Beta也有n张牌, 牌面上数字分别为b1,b2,...,bn.一开始, 他们选择了一个小于等于n的数字m. 然后他们分别从自己的n张牌中随机选择了m张卡. m张卡的和大的那个人赢. Soda想要知道他是否能够必赢, 无论选出来的m张牌是什么.
输入描述
输入有多组数据. 第一行有一个整数T, 表示测试数据组数. 然后对于每组数据:第一行有两个整数 n 和 m (1≤m≤n≤500). 第2行有n个整数a1,a2,...,an (1≤ai≤1000)表示Soda的牌. 第3行有n个整数b1,b2,...,bn (1≤bi≤1000)表示Beta的牌.
输出描述
对于每组数据, 如果Soda必赢输出"YES", 否则输出"NO".
输入样例
23 14 5 61 2 35 23 4 7 8 93 4 5 2 3
输出样例
YESNO
/****************************************************/
出题人的解题思路:
Problem 0. Card Game
由于都是随机出牌, Soda要必胜显然是他的最小的m张牌的和要大于Beta最大的m张牌的和.
因为是随机出牌,为了使Soda随机抽取的m张牌之和一定比Beta随机抽取的m张牌之和大,那么要保证Soda拥有的n张牌中最小的m张牌之和需要大于Beta拥有的n张牌中最大的m张牌#pragma comment(linker, "/STACK:1024000000,1024000000")#include<stdio.h>#include<string.h>#include<stdlib.h>#include<queue>#include<stack>#include<math.h>#include<vector>#include<map>#include<set>#include<stdlib.h>#include<cmath>#include<string>#include<algorithm>#include<iostream>#define exp 1e-10using namespace std;const int N = 505;const int inf = 1000000000;const int mod = 2009;int a[N],b[N];int main(){ int t,i,n,m,sum1,sum2; scanf("%d",&t); while(t--) { sum1=sum2=0; scanf("%d%d",&n,&m); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n;i++) scanf("%d",&b[i]); sort(a,a+n); sort(b,b+n); for(i=0;i<m;i++) sum1+=a[i]; for(i=0;i<m;i++) sum2+=b[n-1-i]; if(sum1>sum2) puts("YES"); else puts("NO"); } return 0;}菜鸟成长记
0 0
- HDU 5494 Card Game(排个序就可以了)——BestCoder Round #58(div.2)
- hdu5494 Card Game(BestCoder Round #58 (div.2))
- BestCoder Round #58 (div.2)Card Game(hdu5494)
- BestCoder Round #58 (div.2)HDU5494 Card Game
- HDU 5523 Game(就是情况比较多,讨论全了就可以了)——BestCoder Round #61(div.1 div.2)
- hdu 5523 Game 【BestCoder Round #61 (div.2)】
- BestCoder Round #58 (div.2)(hdu 5494,hdu5495,hdu5496)
- HDU 5495 LCS(其实就是找环)——BestCoder Round #58(div.1 div.2)
- HDU 5670 Machine——BestCoder Round #81(div.2)
- HDU 5480 Conturbatio(傻傻的我用了线段树)——BestCoder Round #57(div.1 div.2)
- BestCoder Round #58 Card Game 即 hdu5494 (排序)
- BestCoder Round #61 (div.2) HDU5523 Game
- BestCoder Round #61 (div.2) Game
- HDU 5366 The mook jong——BestCoder Round #50(div.1 div.2)
- HDU 5365 Run ——BestCoder Round #50(div.1 div.2)
- HDU 5428 The Factor——BestCoder Round #54(div.1 div.2)
- HDU 5429 Geometric Progression(大数模板)——BestCoder Round #54(div.1 div.2)
- HDU 5569 matrix(DP)——BestCoder Round #63(div.1 div.2)
- sql性能优化 - 数据库对象优化
- python第一课~兔子在欢乐的度假期~
- sql server查看当前进程、死锁进程, 并杀掉死进程
- Apache容器扩展类和常用方法
- 安卓控件使用系列31:ViewStub惰性装载控件的使用方法
- HDU 5494 Card Game(排个序就可以了)——BestCoder Round #58(div.2)
- LeetCodeOJ_202_Happy Number
- HDU2054 A==B?
- HDU 5491 The Next 2015 ACM/ICPC Asia Regional Hefei Online1008
- eclipse主题颜色配置
- C++ static、const和static const 以及它们的初始化
- iOS大典之UIScrollView
- [INS-41112] Specified network interface doesnt maintain connectivity across cluster nodes.
- Cordova从零开始插件开发-支付宝插件(一)