博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1280 前m大的数
阅读量:6859 次
发布时间:2019-06-26

本文共 999 字,大约阅读时间需要 3 分钟。

前m大的数

http://acm.hdu.edu.cn/showproblem.php?pid=1280

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 6323    Accepted Submission(s): 2235

Problem Description
还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大的M个数告诉她就可以了。 
给定一个包含N(N<=3000)个正整数的序列,每个数不超过5000,对它们两两相加得到的N*(N-1)/2个和,求出其中前M大的数(M<=1000)并按从大到小的顺序排列。
 

 

Input
输入可能包含多组数据,其中每组数据包括两行: 
第一行两个数N和M, 
第二行N个数,表示该序列。
 

 

Output
对于输入的每组数据,输出M个数,表示结果。输出应当按照从大到小的顺序排列。
 

 

Sample Input
 
4 4
1 2 3 4
4 5
5 3 6 4
 

 

Sample Output
 
7 6 5 5
11 10 9 9 8
 

 

Author
Gardon
 

 

Source
 
 
 
#include
#include
#include
#include
#include
using namespace std;int a[3010],b[10010],res[3010];int main(){ //freopen("input.txt","r",stdin); int n,m; while(~scanf("%d%d",&n,&m)){ for(int i=0;i
=0;i--){ while(b[i]!=0){ res[cnt++]=i; b[i]--; if(cnt==m) break; } if(cnt==m) break; } for(int i=0;i

 

转载地址:http://nuxyl.baihongyu.com/

你可能感兴趣的文章
搜狗拼音输入法 V9.1.0.2589 最新去广告精简优化版
查看>>
Centos7.4和Ubuntu18.04安装PHP7.2
查看>>
25岁,可能是人生最尴尬的一个年龄
查看>>
dotnet core 开发无缝兼容Http和Websocket协议的接口服务
查看>>
对啊英语音标---四、双元音常见的字母发音组合有哪些
查看>>
Resource 定位、BeanDefinition 的载入和解析,BeanDefinition 注册。
查看>>
PHP模拟登录发送闪存
查看>>
com.sun.mirror的jar包
查看>>
非常详尽的 Shiro 架构解析
查看>>
负载均衡获得真实源IP的6种方法 【转】
查看>>
Windows远程协助相关汇总
查看>>
MySql(十六):MySql架构设计——MySQL Cluster
查看>>
HTML5手机页面里面如何把长按复制避免
查看>>
模拟Spring中applicationContext.xml配置文件初始化bean的过程
查看>>
Signal Shading Theory?
查看>>
[转]ASP.NET HttpModule for handling session end with StateServer
查看>>
Creating and Using Static Libraries for iPhone using Xcode 4.3
查看>>
OkHttp3几个简单的例子和在子线程更新UI线程的方法
查看>>
Flash lite for Windows Mobile?!
查看>>
(原創) DE2_NIOS_Lite 1.2 (SOC) (Nios II) (SOPC Builder) (DE2)
查看>>