CF234B.Reading

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Vasya is going to the Olympics in the city Ntown by train. The boy wants to read the textbook to prepare for the Olympics. He counted that he needed k hours for this. He also found that the light in the train changes every hour. The light is measured on a scale from 0 to 100, where 0 is very dark, and 100 is very light.

Vasya has a train lighting schedule for all n hours of the trip — n numbers from 0 to 100 each (the light level in the first hour, the second hour and so on). During each of those hours he will either read the whole time, or not read at all. He wants to choose k hours to read a book, not necessarily consecutive, so that the minimum level of light among the selected hours were maximum. Vasya is very excited before the upcoming contest, help him choose reading hours.

瓦西娅将乘坐火车前往 N 城参加奥林匹克竞赛。这个男孩想阅读教材来为奥林匹克竞赛做准备。他计算出自己需要 kk 小时来完成阅读。他还发现火车内的光照强度每小时都会变化。光照强度用 0 到 100 的刻度衡量,其中 0 表示非常昏暗,100 表示非常明亮。

瓦西娅掌握了整个 nn 小时旅程中每小时的列车照明计划——即 nn 个介于 0 到 100 之间的数(分别表示第 1 小时、第 2 小时……的光照强度)。在这些小时中的每一小时里,他要么全程阅读,要么完全不读。他希望从中选出 kk 小时来读书(不一定是连续的),使得所选小时中最小的光照强度值尽可能大。瓦西娅对即将到来的比赛感到十分激动,请你帮他选出合适的阅读时段。

输入格式

The first input line contains two integers n and k (1 ≤ n ≤ 1000, 1 ≤ k ≤ n) — the number of hours on the train and the number of hours to read, correspondingly. The second line contains n space-separated integers a__i (0 ≤ a__i ≤ 100), a__i is the light level at the i-th hour.

第一行输入包含两个整数 nn 和 kk(1 ≤ n ≤ 10001 \le n \le 1000,1 ≤ k ≤ n1 \le k \le n),分别表示火车上的小时数和需要阅读的小时数。
第二行包含 nn 个用空格分隔的整数 aia_i(0 ≤ ai ≤ 1000 \le a_i \le 100),其中 aia_i 表示第 ii 小时的光照强度。

输出格式

In the first output line print the minimum light level Vasya will read at. In the second line print k distinct space-separated integers _b_1, _b_2, ..., b__k, — the indexes of hours Vasya will read at (1 ≤ b__i ≤ n). The hours are indexed starting from 1. If there are multiple optimal solutions, print any of them. Print the numbers b__i in an arbitrary order.

在第一行输出瓦西娅阅读时的最低光照强度。
第二行输出 kk 个互不相同的、以空格分隔的整数 b1, b2, …, bkb_1,\ b_2,\ \dots,\ b_k,表示瓦西娅将进行阅读的时刻的索引(1≤bi≤n1\leq b_i\leq n)。时刻从 1 开始编号。若存在多个最优解,输出任意一个即可。数字 bib_i 可按任意顺序输出。

输入输出样例

  • 输入#1

    5 3
    20 10 30 40 10

    输出#1

    20
    1 3 4
  • 输入#2

    6 5
    90 20 35 40 60 100

    输出#2

    35
    1 3 4 5 6

说明/提示

In the first sample Vasya should read at the first hour (light 20), third hour (light 30) and at the fourth hour (light 40). The minimum light Vasya will have to read at is 20.

在第一个样例中,瓦西娅应在第一小时(光照强度为 20)、第三小时(光照强度为 30)和第四小时(光照强度为 40)阅读。瓦西娅需要阅读的最小光照强度为 20。

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

首页