[CF733D]Kostya the Sculptor(贪心)
题目链接: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(贪心)的更多相关文章
- CF733D Kostya the Sculptor[贪心 排序]
D. Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input stand ...
- 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 ...
- Codeforces378 D Kostya the Sculptor(贪心)(逻辑)
Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Kostya the Sculptor
Kostya the Sculptor 题目链接:http://codeforces.com/problemset/problem/733/D 贪心 以次小边为第一关键字,最大边为第二关键字,最小边为 ...
- Codeforces Round #378 (Div. 2) D - Kostya the Sculptor
Kostya the Sculptor 这次cf打的又是心累啊,果然我太菜,真的该认真学习,不要随便的浪费时间啦 [题目链接]Kostya the Sculptor &题意: 给你n个长方体, ...
- 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 ...
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor 分组 + 贪心
http://codeforces.com/contest/733/problem/D 给定n个长方体,然后每个长方体都能选择任何一个面,去和其他长方体接在一起,也可以自己一个,要求使得新的长方体的最 ...
- Kostya the Sculptor(贪心
这题本来 想二分.想了很久很久,解决不了排序和二分的冲突. 用贪心吧.. 题意: 给你n个长方形,让你找出2个或1个长方体,使得他们拼接成的长方体的内接球半径最大(这是要求最短边越大越好)( ...
- 【25.47%】【codeforces 733D】Kostya the Sculptor
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- sql2005镜像实现
-- =========================================== -- 无论是主体服务器.镜像服务器, 还是见证服务器 -- 除特别说明外,均需要保证下面的操作 ...
- 背包问题(Knapsack problem)采用动态规划求解
问题说明: 假设有一个背包的负重最多可达8公斤,而希望在背包中装入负重范围内可得之总价物品,假设是水果好了,水果的编号.单价与重量如下所示:0李子4KGNT$45001苹果5KGNT$57002橘子2 ...
- iOS 学习笔记 十三 (2015.04.15)采用第三方库,实现ios录音转为amr
1.第三方开源库地址 https://github.com/guange2015/ios-amr 2.参考博客地址 http://blog.csdn.net/windsoul85/article/de ...
- java继承关系中成员变量,构造方法,成员方法的关系
Java继承中的成员关系 A:成员变量 a:子类的成员变量名称和父类中的成员变量名称不一样,这个太简单写那个名字就访问那个名字! b:子类的成员变量名称和父类中的成员变量名称一样,这个怎么访问呢? 子 ...
- Asp.Net Web Api 2 实现多文件打包并下载文件示例源码_转
一篇关于Asp.Net Web Api下载文件的文章,之前我也写过类似的文章,请见:<ASP.NET(C#) Web Api通过文件流下载文件到本地实例>本文以这篇文章的基础,提供了Byt ...
- Mysql slow query log
一.概念部分: 顾名思义,慢查询日志中记录的是执行时间较长的query,也就是我们常说的slow query,通过设--log-slow-queries[=file_name]来打开该功能并设置记录 ...
- WPF:获取控件内的子项
一.界面内容(部分:仅供参考) <Window> <Window.Resources> <!--工具数据源--> <XmlDataProvider x:Key ...
- git 本地分支与远程分支关联的一种方法
github上已经有master分支 和dev分支 在本地 git checkout -b dev 新建并切换到本地dev分支 git pull origin dev 本地分支与远程分支相关联 在本地 ...
- [c++][语言语法]函数模板和模板函数 及参数类型的运行时判断
参考:http://blog.csdn.net/beyondhaven/article/details/4204345 参考:http://blog.csdn.net/joeblackzqq/arti ...
- HttpClient的使用方法
使用httpClient发送请求.接收响应很简单.一般需要以下几个步骤. 第一:创建HttpClient对象: 第二:创建请求方法的实例,并指定请求URL.如果要发送GET请求,创建HttpGet对象 ...