排序+搜索 为什么这是对的呢?其实我不是很清楚 大概是这个样子的:我们希望构成三角形的三个数尽可能集中,因此在搜索中贪心地选取从最小依次往上,选取三条边,但是总感觉有反例,先挖个坑。。。

#include<iostream>
#include<algorithm>
#include<Cstdio>
using namespace std;
int n,ans;
long long x[],a[],used[];
inline bool cp(int x,int y)
{
return x<y;
}
bool dfs(int d,int pos)
{
if(d==)
{
if(x[]+x[]>x[]&&x[]+x[]>x[]&&x[]+x[]>x[])
{
ans++;
return true;
}
return false;
}
for(int i=pos+;i<=n;i++)
{
if(!used[i])
{
used[i]=;
x[d]=a[i];
if(dfs(d+,i))return true;
used[i]=;
x[d]=;
}
}
return false;
}
int main()
{
scanf("%d",&n);
int tot=n;
for(int i=;i<=n;i++)
scanf("%I64d",&a[i]);
sort(a+,a+n+,cp);
while(tot>)
{
if(dfs(,))tot-=;
else break;
}
printf("%d\n",ans);
return ;
}

100735D的更多相关文章

  1. CodeForcesGym 100735D Triangle Formation

    Triangle Formation Time Limit: Unknown ms Memory Limit: 65536KB This problem will be judged on CodeF ...

随机推荐

  1. 有关数据库行、锁 的几个问题(rowlock)

    行锁的基本说明: SELECT au_lname FROM authors WITH (NOLOCK) 锁定提示                                 描述  HOLDLOC ...

  2. [No000018]都在背单词,为啥学霸那么厉害-如何在一天内记200个单词?

  3. [No000008]发工资不仅仅是让你写代码的

    这是我对团队每个新进员工说的第一件事情.这句话的意思是,我并不关心你是如何快速完成任务的,哪怕代码很差,只要它像救生艇通气门一样管用就行.这句话也是我最喜欢的座右铭之一. 这个说法其实很合理:我们的工 ...

  4. HTML 学习笔记 CSS样式(背景)

    背景色 可以使用background-color属性为元素设置背景色 这个属性接受任何合法的颜色值. 可以使用background-image属性来喂元素设置背景图片. 背景重复 如果需要在页面上对背 ...

  5. WARN util.NativeCodeLoader: Unable to load native-hadooplibrary for your platform… using builtin-java classes where applicable

    方法1glibc 官方要求的2.14版本以上 方法2:http://www.secdoctor.com/html/yyjs/31101.html 方法3: http://dl.bintray.com/ ...

  6. ip的划分,超详细

    from:http://blog.liuts.com/post/128/ IP和子网掩码我们都知道,IP是由四段数字组成,在此,我们先来了解一下3类常用的IP A类IP段 0.0.0.0 到127.2 ...

  7. Basic: Fisher's transform

    来源:http://bbs.chinahrd.net/thread-709742-1-1.html,Kenneth的回答. z = 0.5 * ln [ (1+r)/(1-r) ]" C0 ...

  8. 浅析MySQL数据碎片的产生(data free)

    浅析MySQL数据碎片的产生 2011-03-30 09:28 核子可乐译 51CTO 字号:T | T MySQL列表,包括MyISAM和InnoDB这两种最常见的类型,而根据经验来说,其碎片的产生 ...

  9. xpath 参考

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Te ...

  10. python学习之用正则处理log(持续更新,ftace)

    1. ftrace的输出如下图所示: [003] 48375.494595: clear_buddies <-pick_next_entity m=re.match("^\[([0-9 ...