原题链接:http://codeforces.com/contest/984/problem/A

Game

Two players play a game.

Initially there are nnn integers a1,a2,⋯,an" role="presentation" style="position: relative;">a1,a2,⋯,ana1,a2,⋯,ana_1,a_2,\cdots,a_n written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on the board, i. e. n−1n−1n−1 turns are made. The first player makes the first move, then players alternate turns.

The first player wants to minimize the last number that would be left on the board, while the second player wants to maximize it.

You want to know what number will be left on the board after n−1n−1n−1 turns if both players make optimal moves.

Input

The first line contains one integer $n (1≤n≤1000) — the number of numbers on the board.

The second line contains nnn integers a1,a2,⋯,an(1≤ai≤106)" role="presentation" style="position: relative;">a1,a2,⋯,an(1≤ai≤106)a1,a2,⋯,an(1≤ai≤106)a_1,a_2,\cdots,a_n (1≤a_i≤10^6).

Output

Print one number that will be left on the board.

Examples
input

3
2 1 3

output

2

input

3
2 2 2

output

2

Note

In the first sample, the first player erases 333 and the second erases 1" role="presentation" style="position: relative;">111. 222 is left on the board.

In the second sample, 2" role="presentation" style="position: relative;">222 is left on the board regardless of the actions of the players.

题解

贪心一下,第一个人肯定会选大的,第二个人选小的,最后剩的就是中间的了。

第一次看反了,getgetget A题−1−1-1,我怎么这么菜

代码
#include<bits/stdc++.h>
using namespace std;
const int M=1005;
int a[M],n;
void in(){scanf("%d",&n);for(int i=1;i<=n;++i)scanf("%d",&a[i]);}
void ac(){sort(a+1,a+1+n);printf("%d",a[(n+1)/2]);}
int main(){in();ac();}

CF984A Game相关推荐

  1. Codeforces 刷题记录(已停更)

    Codeforces 每日刷题记录 (已停更) 打'+'是一些有启发意义的题目,部分附上一句话题解,每日更新3题,大部分题目较水. Day ID Problem Tutorial Note 1 1 + ...

最新文章

  1. 异常处理与MiniDump详解(3) SEH(Structured Exception Handling)
  2. C++五子棋(三)——判断鼠标有效点击
  3. Silverlight 1.0 RC SDK 预览
  4. ibatis中主键自动增长(Oracle,Ms sql server ,mysql)
  5. Java反序列化json内存溢出_反序列化JSON时出现线程错误
  6. c语言 fgets函数 去除换行符_C语言文件的打开和关闭
  7. user-select属性用法
  8. 单片机float数发给上位机_上位机倒计时器
  9. react学习(16)---getFieldDecorator赋值
  10. 查询字符串某个字符的个数
  11. dbForge mysql数据库比对
  12. Linux系统下init进程的前世今生
  13. Java LP1_Java Performance 总结(1. Class Loader)
  14. c++ 银行管理系统
  15. 软件测试入门基础自卸
  16. STM32 独立按键扫描功能大全-支持连击、组合连击、任意连击
  17. shader函数整理
  18. 今天谁在开网店?兼职卖家占整体网店近70%
  19. 设置div中的背景颜色及div中的字体颜色
  20. 除了迅雷,目前还有什么下载软件好用?以下这3款你听过吗?

热门文章

  1. Karta:IDA源代码辅助插件
  2. win8文件共享服务器搭建,Win8系统开启公用文件夹共享的方法【图文】
  3. PL/SQL Developer使用技巧、快捷键(转发)
  4. BZOJ 5106 [CodePlus2017]汀博尔
  5. selenium+python在Windows的环境搭建
  6. 【转】博客美化(6)为你的博文自动添加目录
  7. Android 内存监测工具 DDMS -- Heap
  8. Android Service使用需要注意事项
  9. printf格式控制符的完整格式
  10. [导入]意外的,博客被点名了。参与游戏吧。