Codeforces 845A Chess Tourney
来源:互联网 发布:mysql终端查看数据库 编辑:程序博客网 时间:2024/05/16 17:06
Berland annual chess tournament is coming!
Organizers have gathered 2·n chess players who should be divided into two teams withn people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers should guarantee the win for the team of BerOil.
Thus, organizers should divide all 2·n players into two teams withn people each in such a way that the first team always wins.
Every chess player has its rating ri. It is known that chess player with the greater rating always wins the player with the lower rating. If their ratings are equal then any of the players can win.
After teams assignment there will come a drawing to form n pairs of opponents: in each pair there is a player from the first team and a player from the second team. Every chess player should be in exactly one pair. Every pair plays once. The drawing is totally random.
Is it possible to divide all 2·n players into two teams withn people each so that the player from the first team in every pair winsregardless of the results of the drawing?
The first line contains one integer n (1 ≤ n ≤ 100).
The second line contains 2·n integers a1, a2, ...a2n (1 ≤ ai ≤ 1000).
If it's possible to divide all 2·n players into two teams withn people each so that the player from the first team in every pair wins regardless of the results of the drawing, then print"YES". Otherwise print "NO".
21 3 2 4
YES
13 3
NO题目大意:把2n个数,等分成两组,能不能一组的任意个比另一组的任意一个数都大。
一开始觉得这题很难,然后写了一下发现排一下序就行了.....排序后,如果第一组的最后一个比第二组的最后一个小就可以YES了
#include<bits/stdc++.h>using namespace std;int num[500];int main(){int n;cin>>n;for(int i=0;i<2*n;i++) scanf("%d",&num[i]);sort(num,num+2*n);if(num[n-1]<num[n]) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
- codeforces 845A Chess Tourney
- Codeforces 845 A Chess Tourney
- codeforces 845A Chess Tourney
- Codeforces 845A Chess Tourney
- Codeforces 845 A. Chess Tourney 思路:简单逻辑题
- A. Chess Tourney【Educational Codeforces Round 27】
- cfA.Chess Tourney
- codeforces 7A - Kalevitch and Chess
- Codeforces 7A Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- codeforces 7 A. Kalevitch and Chess
- CodeForces 7A - Kalevitch and Chess
- CodeForces 7A Kalevitch and Chess
- Codeforces 7A Kalevitch and Chess
- Codeforces 664A Gerald and Giant Chess
- CodeForces 893A Chess For Three
- C# --- 其他信息: @xxx不是过程xxx的参数。
- 写一个简单的自定义UITabelView
- SpringBoot集成分页插件PageHelper
- Hbase的JavaApi和工具类
- Hadoop2.7.4集群的Linux安装步骤
- Codeforces 845A Chess Tourney
- relation window窗口source insight查看函数的上一级调用
- 基于JQuery的轮播图插件nivo-slider使用教程
- 最近在编写一些bat工具时,发现自己对lua的io和正则表达式使用没什么了解,网络上转载解决问题后的文章。
- Node.js的安装
- [LeetCode] 373. Find K Pairs with Smallest Sums
- ospf不同进程下的邻居状态
- 用最小二乘法拟合一元线性方程y=ax+b
- mediawiki常用设置