哈希表..球阀
代码:
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
bool hash[];
int main()
{
int c,n,k,i,j;
scanf("%d",&c);
while(c--)
{
scanf("%d%d",&n,&k);
memset(hash,,sizeof(hash));
vector<int>sav(n);
for(i=;i<n;i++)
scanf("%d",&sav[i]);
sort(sav.begin(),sav.end(),less<int>());
for(i=;i<n;i++)
{
for(j=i+;j<n ;j++)
{
hash[sav[j]-sav[i]]=true;
}
}
for(i=;i<=&&k>;i++)
{
if(hash[i]) k--;
}
printf("%d\n",i-);
}
return ;
}

想到过很多方法,都超时了,看了别人的代码,才发现,有这么一出,居然没想到...爱,菜鸟,终究是菜鸟...

最新文章

  1. hive 内部表和外部表的区别和理解
  2. idea key
  3. jQuery简单入门(三)
  4. JBOSS只能本机localhost和127.0.0.1能访问的解决
  5. cocos2dx 3.0 之 lua 创建类 (二)
  6. 设置Tomcat根目录
  7. LeetCode 278
  8. 查看linux中的TCP连接数【转】
  9. 第一篇、CSS3_transtion的使用
  10. 关于 ASP.NET MVC 4 如果管理用户
  11. 使用Bugfree不应有的坏习惯
  12. opencv基础知识-videowriter
  13. [转]CSS vertical-align属性详解 作者:黄映焜
  14. Activity的onSaveInstanceState()和onRestoreInstanceState()以及API详解
  15. [Python]How to handle the exception in Python?
  16. 九、使用多线程——NSThread,GCD和NSOperation
  17. 《Android进阶之光》--RxJava结合Retrofit访问网络
  18. Android UI系列-----RelativeLayout的相关属性
  19. ajax post get
  20. [knowledge][bigdata] nosql

热门文章

  1. RuntimeError: Working outside of application context.
  2. 21.重入锁ReentrantLock
  3. C 语言:返回两个数组中第一个相同元素的指针(我用了loop 、goto loop标签)
  4. WampServer和phpStorm的用法
  5. Entity Framework泛型封装
  6. HDU 4576 Robot (概率DP)
  7. MFC COM调用时出现E_OUTOFMEMORY错误
  8. 如何在程序中使用CString
  9. Java 正则表达式提取标签中的属性(src 连接地址)等
  10. 【nodejs】理想论坛帖子下载爬虫1.06