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

题意:

  给你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. Egret入门学习日记 --- 第十六篇(书中 6.10~7.3节 内容)

    第十六篇(书中 6.10~7.3节 内容) 昨天搞定了6.9节,今天就从6.10节开始. 其实这个蛮简单的. 这是程序员模式. 这是设计师模式. 至此,6.10节 完毕. 开始 6.11节. 有点没营 ...

  2. 【数据库开发】Redis数据库设置密码

    redis配置密码1.通过配置文件进行配置yum方式安装的redis配置文件通常在/etc/redis.conf中,打开配置文件找到 ? 1 #requirepass foobared 去掉行前的注释 ...

  3. 冲刺Noip2017模拟赛8 解题报告——五十岚芒果酱

    1.鼎纹 [问题描述] 据说鼎纹的 种制造 式是 铜模印出来的,这是我国古代劳动 智慧 的结晶.铜模印过的地 ,会留下深深的印记,经过时间的炼化,洗 练成历史的遗存. 聪明的古代劳动人民拥有一个 a ...

  4. Oracle 表的导入与导出

    周末任务:将一个表从一个库导到另一个库大致思路:用expdp 将表从一个实例导出 ,再用impdp将导出的 .dmp文件导入到另一个实例1.在实例 orcl 中准备一个用于导出的表: 进入实例为orc ...

  5. K8S从入门到放弃系列-(9)kubernetes集群之kubelet部署

    摘要: Kubelet组件运行在Node节点上,维持运行中的Pods以及提供kuberntes运行时环境,主要完成以下使命: 1.监视分配给该Node节点的pods 2.挂载pod所需要的volume ...

  6. 变量————if语句——结构使用

    1简述变量的命名规范 变量是以字母 数字 下划线组合而成 不能以数字开头 不能使用python中的关键字命名 变量要具有可描述性 区分大小写 name变量是什么数据类型通过代码检测 name = in ...

  7. 1192: 零起点学算法99——The sum problem(C)

    一.题目 http://acm.wust.edu.cn/problem.php?id=1192&soj=0 二.分析 要求从序列1,2,3,,,N,中截取一部分使他们的和为M 输入多组数据 输 ...

  8. java类的访问修饰符

    1.java中外部类的访问修饰符有如下四种: public,默认,abstract,final // public,默认,abstract,final. public class Test1 {} c ...

  9. 开发人员需求能kill杀死其它阻塞自己的会话,测试发现需要alter system权限有风险

    模拟开发人员需求,可以杀死其它阻塞自己的会话1.能有查询阻塞会话确认的权限SQL> grant select on v_$session to testa;SQL> grant selec ...

  10. 16-MySQL DBA笔记-调优基础理论和工具

    第五部分 性能调优与架构篇 本篇将为读者介绍性能调优的一些背景知识和理论,然后介绍一些工具的运用,最后介绍从应用程序到操作系统.到数据库.到存储各个环节的优化. 性能调优是一个高度专业的领域,它需要一 ...