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

题意:

  给你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. 给.Net Core添加Swagger实现接口文档自动生成

    1.添加Nuget相关引用 Swashbuckle.AspNetCore

  2. python3.7.3安装beautifulsoup4出现版本不兼容的问题

    今天想安装一个beautifulsoup4,结果一直出错,好多教程总是有各种坑……找了很多个教程,为了记录方法也为了分享给大家,简单些一个.但是是真真不想再费劲写一遍了……直接贴链接,亲测有效,但是底 ...

  3. 【计算机视觉】纹理特征之LBP局部二值化模式

    转自http://blog.csdn.NET/ty101/article/details/8905394 本文的PDF版本,以及涉及到的所有文献和代码可以到下列地址下载: 1.PDF版本以及文献:ht ...

  4. H5本地存储(转)

    H5本地存储  一.本地存储由来的背景         众所周知Html4时代Cookie的大小.格式.存储数据格式等限制,网站应用如果想在浏览器端存储用户的部分信息,那么只能借助于Cookie.但是 ...

  5. Asp.Net Core 客户端验证和远程验证

    我们先来看这样一个注册页面和它的后台Model @model RegisterViewModel @{ ViewBag.Title = "用户注册"; } <h1>用户 ...

  6. vue-cli webpack打包后加载资源的路径问题

    vue项目,访问打包后的项目,输入路径后,页面加载空白.这时会有两类问题,都是路径问题. 1.一个是css,js,ico等文件加载不到,是目录里少了dist 打开页面时一片空白 解决办法: confi ...

  7. JAVA_split 字符串按照 . 分割

    split 按照 . 分割字符串时 需要进行转义 代码: String[] str = obj_str.split("\\.") split 按照 \ 分割字符串时 需要多次转义 ...

  8. Ettercap 帮助文档

    Ettercap(8)帮助 (翻译来自百度翻译,原文附于文后,个人润色) 1.概述 Ettercap-多用途嗅探器/内容过滤器,用于中间人攻击 重要提示 自Ettercap Ng(以前为0.7.0)以 ...

  9. Django自定义分页并保存搜索条件

    Django自定义分页并保存搜索条件 1.自定义分页组件pagination.py import copy class Pagination: def __init__(self, current_p ...

  10. 十四、i2c子系统

    由于之后的触摸屏驱动分析中使用到了GPIO子系统和i2c子系统,因此在分析触摸屏驱动之前我准备把这两个子系统进行简单分析. 在读者学习本章以及后续i2c相关章节之前,最好了解i2c通信方式,可以参考: ...