题目链接:http://codeforces.com/contest/733/problem/D

题意:给n个长方体,允许最多两个拼在一起,拼接的面必须长宽相等。问想获得最大的内切圆的长方体序号是多少。最多拼2个,可以不拼。

最大内切圆与最短的边有关系,在读入的时候做只取一个的情况,接下来按照边长从大到小排序,之后按照最大边依次排序,取相邻的两个拼接在一起看看是否更大。

 #include <bits/stdc++.h>
using namespace std; typedef struct S {
int x, y, z, id;
S(){}
S(int xx, int yy, int zz) {
if(xx < yy) swap(xx, yy);
if(xx < zz) swap(xx, zz);
if(yy < zz) swap(yy, zz);
x = xx; y = yy; z = zz;
}
bool operator <(const S b) const {
if(x == b.x) {
if(y == b.y) return z > b.z;
return y > b.y;
}
return x > b.x;
}
bool operator ==(const S b) const {
return x == b.x && y == b.y && z == b.z;
}
S operator +(const S b) const {
return S(x,y,z+b.z);
}
}S;
typedef pair<int,int> pii;
const int maxn = ;
int n, ret, id1, id2;
S s[maxn]; int main() {
// freopen("in", "r", stdin);
int x, y, z;
while(~scanf("%d", &n)) {
ret = ; id2 = -;
for(int i = ; i <= n; i++) {
scanf("%d%d%d",&x,&y,&z);
s[i] = S(x, y, z);
s[i].id = i;
if(ret < s[i].z) {
ret = s[i].z;
id1 = i;
}
}
sort(s+, s+n+);
for(int i = ; i <= n - ; i++) {
if(s[i].x==s[i+].x&&s[i].y==s[i+].y) {
S t = s[i] + s[i+];
if(ret < t.z) {
ret = t.z;
id1 = s[i].id; id2 = s[i+].id;
if(id1 > id2) swap(id1, id2);
}
}
}
if(id2 == -) {
printf("%d\n%d\n", , id1);
}
else {
printf("%d\n%d %d\n", , id1, id2);
}
}
return ;
}

[CF733D]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. Kostya the Sculptor(贪心

    这题本来  想二分.想了很久很久,解决不了排序和二分的冲突.     用贪心吧.. 题意: 给你n个长方形,让你找出2个或1个长方体,使得他们拼接成的长方体的内接球半径最大(这是要求最短边越大越好)( ...

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

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

随机推荐

  1. z/os上的tar和gzip(3)

    前面两篇文章分别讲过了如何合并并压缩批量文件,如何解压缩并恢复批量文件, 这些问题解决了之后还剩下一个大问题,如何在网络上传输这些压缩过的文件,如果是linux的话非常简单,制定binary,然后ge ...

  2. Android上传头像代码,相机,相册,裁剪

    activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout ...

  3. Sublime Text 3 常用插件以及安装方法

    安装Sublime Text 3插件的方法: 一.直接安装 安装Sublime text 2插件很方便,可以直接下载安装包解压缩到Packages目录(菜单->preferences->p ...

  4. Perl的基本语法<总结> (转载)

    前言:这篇文章是花了我很多时间.费了我很多心血才完成的,虽然连我自己都觉得无法达到尽善尽美的境界,但希望能帮助大家入门,稍微了解到Perl 到底是个什么样的东西,Perl到底有那些强大的功能,那么这篇 ...

  5. Oracle:Authid Current_User使用

    由于用户拥有的role权限在存储过程是不可用的.遇到这种情况,我们一般需要显示授权,如grant create table to user;但这种方法太麻烦,有时候可能需要进行非常多的授权才能执行存储 ...

  6. PHP和Java的主要区别有哪些呢?

    解释 PHP与Java作为两种截然不同的程序开发语言,无论是技术层面还是发展空间,亦或是市场份额占比,都有着不同的表现方式,理念上的不同导致了Java和PHP在Web应用开发上显示了不同的结果.若要一 ...

  7. SQL编程之高级查询(子查询)以及注意事项

    SQL编程之高级查询(子查询)以及注意事项   1.什么是子查询? 当一个查询是另一个查询的条件时,称之为子查询.子查询可以使用几个简单命令构造功能强大的复合命令.子查询最常用于SELECT-SQL命 ...

  8. 优秀的web前端工程师要具备什么

    优秀的前端工程师需要具备良好的沟通能力,因为你的工作与很多人的工作息息相关.在任何情况下,前端工程师至少都要满足下列四类客户的需求. 产品经理--这些是负责策划应用程序的一群人.他们能够想象出怎样通过 ...

  9. ArrayList集合的实现原理

    一. ArrayList概述: ArrayList是基于数组实现的,是一个动态数组,其容量能自动增长,类似于C语言中的动态申请内存,动态增长内存. ArrayList不是线程安全的,只能用在单线程环境 ...

  10. JavaScript DOM 编程艺术(第2版)读书笔记(1)

    JavaScript 简史 JavaScript 是Netscape公司与Sun公司合作开发的.在 JavaScript 1.0发布时,Netscape Navigator主宰着浏览器市场.微软在推出 ...