CF412B.Network Configuration

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the result. The higher the speed of the Internet is, the faster the participant will find the necessary information. Therefore, before the competition started, each computer had its maximum possible data transfer speed measured. On the i-th computer it was a__i kilobits per second.

There will be k participants competing in the championship, each should get a separate computer. The organizing company does not want any of the participants to have an advantage over the others, so they want to provide the same data transfer speed to each participant's computer. Also, the organizers want to create the most comfortable conditions for the participants, so the data transfer speed on the participants' computers should be as large as possible.

The network settings of the R1 company has a special option that lets you to cut the initial maximum data transfer speed of any computer to any lower speed. How should the R1 company configure the network using the described option so that at least k of n computers had the same data transfer speed and the data transfer speed on these computers was as large as possible?

R1 公司计划举办一场网络搜索锦标赛。比赛共提供 nn 台计算机,每台均接入互联网。主办方认为数据传输速率直接影响比赛成绩:互联网速率越高,参赛者查找所需信息的速度就越快。因此,在比赛开始前,每台计算机的最大可能数据传输速率均已测定;第 ii 台计算机的速率为 aia_i 千比特每秒(kbps)。

锦标赛将有 kk 名参赛者,每人需分配一台独立的计算机。主办方希望确保所有参赛者处于完全公平的竞争环境中,即每位参赛者所用计算机的数据传输速率必须完全相同。同时,主办方也希望为参赛者创造尽可能舒适的条件,因此希望该统一的数据传输速率尽可能大。

R1 公司的网络设置中含有一项特殊功能:可将任意一台计算机的初始最大数据传输速率调整(降低)至任意更低的速率。R1 公司应如何利用该功能进行网络配置,使得在 nn 台计算机中,至少有 kk 台具有相同的数据传输速率,且该速率尽可能大?

输入格式

The first line contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 100) — the number of computers and the number of participants, respectively. In the second line you have a space-separated sequence consisting of n integers: _a_1, _a_2, ..., a__n (16 ≤ a__i ≤ 32768); number a__i denotes the maximum data transfer speed on the i-th computer.

第一行包含两个以空格分隔的整数 nn 和 kk(1 ≤ k ≤ n ≤ 1001 ≤ k ≤ n ≤ 100),分别表示计算机的数量和参赛者的人数。第二行包含一个由 nn 个整数构成的以空格分隔的序列:a1, a2, ..., ana_1, a_2, ..., a_n(16 ≤ ai ≤ 3276816 ≤ a_i ≤ 32768);其中 aia_i 表示第 ii 台计算机的最大数据传输速率。

输出格式

Print a single integer — the maximum Internet speed value. It is guaranteed that the answer to the problem is always an integer.

输出一个整数——最大互联网速度值。题目保证该问题的答案始终为整数。

输入输出样例

  • 输入#1

    3 2
    40 20 30

    输出#1

    30
  • 输入#2

    6 4
    100 20 40 20 50 50

    输出#2

    40

说明/提示

In the first test case the organizers can cut the first computer's speed to 30 kilobits. Then two computers (the first and the third one) will have the same speed of 30 kilobits. They should be used as the participants' computers. This answer is optimal.

在第一个测试用例中,组织者可以将第一台计算机的速度降低至 30 千比特。此时,两台计算机(第一台和第三台)将具有相同的 30 千比特速度,它们应被选为参赛者的计算机。该答案是最优的。

输入解题思路,AI测评打分。不知道怎么写?

首页