Test on 11/17/2018

第一次参加cf比赛,水了一发写了三道水题实在不想写了,然后Rating就低了,好难过哈哈哈哈。

cf#521(div.3)

D:Cutting Out

Description

You are given an array ss consisting of nn integers.

You have to find any array tt of length kk such that you can cut out maximum number of copies of array tt from array ss.

Cutting out the copy of tt means that for each element titi of array tt you have to find titi in ss and remove it from ss. If for some titi you cannot find such element in ss, then you cannot cut out one more copy of tt. The both arrays can contain duplicate elements.

For example, if s=[1,2,3,2,4,3,1]s=[1,2,3,2,4,3,1] and k=3k=3 then one of the possible answers is t=[1,2,3]t=[1,2,3]. This array tt can be cut out 22 times.

  • To cut out the first copy of tt you can use the elements [1,2––,3,2,4,3––,1––][1,2_,3,2,4,3_,1_] (use the highlighted elements). After cutting out the first copy of tt the array ss can look like [1,3,2,4][1,3,2,4].
  • To cut out the second copy of tt you can use the elements [1––,3––,2––,4][1_,3_,2_,4]. After cutting out the second copy of tt the array ss will be [4][4].

Your task is to find such array tt that you can cut out the copy of tt from ss maximum number of times. If there are multiple answers, you may choose any of them.

Input

The first line of the input contains two integers nn and kk (1≤k≤n≤2?1051≤k≤n≤2?105) — the number of elements in ss and the desired number of elements in tt, respectively.

The second line of the input contains exactly nn integers s1,s2,…,sns1,s2,…,sn (1≤si≤2?1051≤si≤2?105).

Output

Print kk integers — the elements of array tt such that you can cut out maximum possible number of copies of this array from ss. If there are multiple answers, print any of them. The required array tt can contain duplicate elements. All the elements of tt (t1,t2,…,tkt1,t2,…,tk) should satisfy the following condition: 1≤ti≤2?1051≤ti≤2?105.

Examples

Input

7 3
1 2 3 2 4 3 1

Output

1 2 3 

Input

10 4
1 3 1 3 10 3 7 7 12 3

Output

7 3 1 3

Input

15 2
1 2 1 1 1 2 1 1 2 1 2 1 1 1 1

Output

1 1

Hint

The first example is described in the problem statement.

In the second example the only answer is [7,3,1,3][7,3,1,3] and any its permutations. It can be shown that you cannot choose any other array such that the maximum number of copies you can cut out would be equal to 22.

In the third example the array tt can be cut out 55 times.

正确解法:

原文地址:https://www.cnblogs.com/Kaike/p/9975679.html

时间: 2024-07-31 01:56:50

Test on 11/17/2018的相关文章

2015.11.17 新起点,出发。

今天注册了博客,要开始认真仔细的学习前端技术了.这个博客将作为我学习进度记录.学习笔记整理.心得体会整理等书写记录的工具. —希望苍天不负有心人 2015.11.17

11.14/11.15 Apache和PHP结合 11.16/11.17 Apache默认虚拟主机

11.14/11.15 Apache和PHP结合 编辑:httpd主配置文件/usr/local/apache2.4/conf/httpd.conf 去掉#号 将php7加# Telnet IP+80 端口不通,需要开启iptables防火墙 更改require 更改配置后需要操作才能生效 重新加载服务 增加一行php进行解析 页面显示 结果访问的是源代码 如果遇到php无法解析,需要检查相关的apache的配置文件 (1)检查apache的php 有没有加载php5 查看是否有libphp5.

2015.11.17

CommonJS CommonJs是服务器端模块的规范,Node.js采用了这个规范. 根据CommonJS规范,一个单独的文件就是一个模块.加载模块使用require方法,该方法读取一个文件并执行,最后返回文件内部的exports对象. 例如: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // foobar.js //私有变量 var test = 123; //公有方法 function foobar () {     this.foo =

17.11.17 递归作业

习题(15-1) 前缀表达式 (1010) 描述 前缀表达式是一种把运算符前置的算术表达式,例如普通的表达式2 + 3的前缀表示法为+ 2 3.前缀表达式的优点是运算符之间不必有优先级关系,也不必用括号改变运算次序,例如(2 + 3) * 4的前缀表示法为* + 2 3 4.本题求解前缀表达式的值,其中运算符包括+ - * /四个. 关于输入 输入为一行,其中运算符和运算数之间都用空格分隔,运算数是浮点数. 关于输出 输出为一行,表达式的值.  可直接用printf("%f\n", v

Test on 11/4/2018

来浙理的第一次月赛,嗯我是被大佬吊着打的垃圾. A:优美数 Description 如果一个数中只有少于三个数字是非零的,那么我们称这个数为优美数,我们定义这个优美数的优美程度为这个数所有数字相加的和. 例如优美数有4,200000,10203,其中4的优美度是4,200000的优美度是2,10203的优美度是6. 数字4231,102306,7277420000,就不是啰. 现在问在[L,R]中,有多少个优美度为x的优美数. Input T组数据,T<=5e4. 第一行为组数T. 接下来T行,

2016/11/17

1.单例设计模式 (1)懒汉模式 1 public class Singleton { 2 3 private Singleton() {} 4 private static Singleton singleton = null; 5 // 这里可以加同步锁解决线程安全问题 6 public static Singleton getInstance() { 7 if(singleton == null) { 8 singleton = new Singleton(); 9 } 10 return

Scrum Meeting 11 -2014.11.17

今天和其他两个小组讨论了关于整合问题,在数据库连接等具体方面上还需要继续商讨. 我们小组内部讨论了,这周还是需要在处理整合的同时做项目整体的测试与改进的. Member Today’s task Next task 林豪森 与其他小组商讨整合问题 与其他小组商讨整合问题 宋天舒 优化代码结构,添加注释 测试项目功能实现 张迎春 修复整合存在的bug 测试项目功能实现 黄漠源 优化代码结构,添加注释 优化代码结构,添加注释 黄敬博 修复整合存在的bug 优化代码结构,添加注释 刘翔宇 优化pdf的

Notes of Daily Scrum Meeting(11.17)

今天是第四周的周一,也就是说距离最后发布也只剩下一周的时间,但我们的工程里面还有很多的问题没有解决,我关注过 其他一两个小组,他们的程序基本功能已经都实现了,确实心里蛮紧张的,希望大家给力!昨天是周日,大家都想休息了,所以 就没有继续.我昨天依照现在工作的进度加上了一些工作任务,燃尽图中会有体现,下面的表格是我加上的工作: 队员 工作内容 时间 高孟烨 UI界面的完善和调试 6h 邓亚梅 UI界面的完善和调试 4h 雷元勇 程序测试 4h 王迪 程序测试 4h 下面是今日的团队任务总结: 团队成

stand up meeting 11/17/2015

今日工作总结: 冯晓云:代表组内参加了北航软工M1检查,有幸在工作展开之前先观摩别人的工作,吸取经验和教训:现在看来,当时对往届ASE学员的采访还不够深入,只说统筹分工团结合作还是有些空,具体的任务划分虽然已经比较细致但是还是没有充分调研:印象比较深刻的几点:首先团队的PM很重要,需要统筹整个项目的运作,我们的组相对北航同学的大组比较小,忽视了PM的重要性,而是采取相互监督的方式,能不能落到实处有待工作的证实:然后就是对工作难度的合理规划,有的团队前期划水后面就完不了工,这一点我们组内进行了充分