这题本来  想二分。想了很久很久,解决不了排序和二分的冲突。     用贪心吧。。

题意:

  给你n个长方形,让你找出2个或1个长方体,使得他们拼接成的长方体的内接球半径最大(这是要求最短边越大越好)(两个矩形拼接的条件是

他们有一个面完全相同)

  输入n,输入第 i个长方体的 三条边长度。最多2个长方体拼接。

  输出  不要拼接的"1"和最大能切成内切球的 i  ;或者输出要拼接的“2”和这两个长方体的序号 i 。

如果 两个长方体的边长分别是 3 2 4,3 2 4  。可以拼接成  6 2 4,3 2 8,3 4 4;

显然 3 4 4这种拼法 内切球是最大的。(这里是 想到用贪心的起点)

给所有的长方体记录原来的位置序号,再按边长排序,(下面代码里的cmp)。这样可以保证每个长方体的第三条边都是最小的,

这样两个长方体的第三条边相加起来, 能使两个长方体的最短边得到加强。(类似木桶的短板原理)

 #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
#define se second
#define fi first
const int INF= 0x3f3f3f3f;
const int N=1e5+; int a[],b[];
int n,maxn=; struct note
{
int x,y,z;
int loc;
}q[N]; bool cmp(note r,note t)
{
return (r.x>t.x||
r.x==t.x&&r.y>t.y||
r.x==t.x&&r.y==t.y&&r.z>t.z);
} int main() //(3 2 4 ;3 2 4)3*2*8,6*2*4,3*4*4选的是3*4*4。
{
cin>>n;
int loc=,loc1=,loc2=; //这是要输出的长方体位置
for(int i=;i<=n;i++){
scanf("%d%d%d",&a[],&a[],&a[]);
sort(a,a+);
q[i].z =a[];
q[i].y =a[];
q[i].x =a[];
q[i].loc =i; //记录原来的下标
if(maxn<a[])
{
maxn=a[];
loc=i;
}
}
sort(q+,q++n,cmp);
int sign=; for(int i=;i<n;i++)
{
if(q[i].x==q[i+].x && q[i].y==q[i+].y)
{
b[]=q[i].x; b[]=q[i].y; b[]=q[i].z+q[i+].z;
sort(b,b+);
if(maxn<b[])
{
maxn=b[];
loc1=q[i].loc;
loc2=q[i+].loc;
sign=;
}
}
}
if(sign){
cout<<<<endl;
cout<<loc1<<' '<<loc2;
}
else
cout<<<<endl<<loc;
}

Kostya the Sculptor(贪心的更多相关文章

  1. CF733D Kostya the Sculptor[贪心 排序]

    D. Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input stand ...

  2. codeforces 733D Kostya the Sculptor(贪心)

    Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. K ...

  3. Codeforces378 D Kostya the Sculptor(贪心)(逻辑)

    Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  4. Kostya the Sculptor

    Kostya the Sculptor 题目链接:http://codeforces.com/problemset/problem/733/D 贪心 以次小边为第一关键字,最大边为第二关键字,最小边为 ...

  5. Codeforces Round #378 (Div. 2) D - Kostya the Sculptor

    Kostya the Sculptor 这次cf打的又是心累啊,果然我太菜,真的该认真学习,不要随便的浪费时间啦 [题目链接]Kostya the Sculptor &题意: 给你n个长方体, ...

  6. Codeforces Round #378 (Div. 2) D. Kostya the Sculptor map+pair

    D. Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input stand ...

  7. Codeforces Round #378 (Div. 2) D. Kostya the Sculptor 分组 + 贪心

    http://codeforces.com/contest/733/problem/D 给定n个长方体,然后每个长方体都能选择任何一个面,去和其他长方体接在一起,也可以自己一个,要求使得新的长方体的最 ...

  8. [CF733D]Kostya the Sculptor(贪心)

    题目链接:http://codeforces.com/contest/733/problem/D 题意:给n个长方体,允许最多两个拼在一起,拼接的面必须长宽相等.问想获得最大的内切圆的长方体序号是多少 ...

  9. 【25.47%】【codeforces 733D】Kostya the Sculptor

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. excel自学笔记 from av50264533

    1.函数公式 MINUTE(serial_number)  函数解读 Serial_number 表示一个时间值,其中包含要查找的分钟  函数公式 NOW()  函数解读 显示出现在的时间 计算通话时 ...

  2. 谈谈NPM和Webpack的关系

    为什么有NPM: 当包引入数量很多时管理就成为了一个问题,这个就是npm为开发者行了方便之处,npm已经为你做好了依赖和版本的控制,也就是说使用npm可以让你从繁杂的依赖安装和版本冲突中解脱出来,进而 ...

  3. java中创建线程的方式

    创建线程的方式: 继承thread 实现runnable 线程池 FurureTask/Callable 第一种:继承thread demo1: public class demo1 { public ...

  4. 初始mysql

    数据库操作 查看当前登陆用户: select user(); 登录数据库 mysql -u用户名 -p密码 -h 连接地址 修改当前用用户密码 set password = password('123 ...

  5. python运算符 - python基础入门(7)

    什么是运算符?听着高大上,实际小学生都能把它玩的贼溜.比如:3 + 2 – 5 * 0 = 0 一.算术运算符 简称加减乘除,直接上代码:   a = 10 b = 20 c = 30 # 其实上面三 ...

  6. nginx rewrite 规则

    rewrite功能:使用nginx提供的全局变量或自设定的变量,结合正则表达式和标志位实现url重写以及重定向. 配置域:server,localtion. flag标志位     last : 相当 ...

  7. (JavaScript) 百度地图与腾讯地图坐标转换

    /** * 坐标转换,百度地图坐标转换成腾讯地图坐标 * lng 腾讯经度(pointy) * lat 腾讯纬度(pointx) * 经度>纬度 */ function bMapToQQMap( ...

  8. K8S 从入门到放弃系列文章目录(Kubernetes 1.14)

    1)软件环境 软件 版本 系统 Centos7.5 Kubernetes 1.14.1 Docker 18.09 Calico 3.6 Etcd 3.3.12 2)部署过程简单概要 三台master节 ...

  9. JVM 内存溢出详解(栈溢出,堆溢出,持久代溢出、无法创建本地线程)

    出处:  http://www.jianshu.com/p/cd705f88cf2a 1.内存溢出和内存泄漏的区别 内存溢出 (Out Of Memory):是指程序在申请内存时,没有足够的内存空间供 ...

  10. redis用法分析

    redis基本介绍 redis也是一个内存非关系型数据库,它拥有memcache在数据存储上的全部优点,而且在memcache的基础上增加了数据持久性功能,redis用rdb和aof两种方式实现数据持 ...