[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 ...
随机推荐
- repeater做删除前弹窗询问
前台 <asp:LinkButton ID="delLinkButton" runat="server" OnClientClick='return co ...
- Java笔试题解答和部分面试题
面试类 银行类的问题 问题一:在多线程环境中使用HashMap会有什么问题?在什么情况下使用get()方法会产生无限循环? HashMap本身没有什么问题,有没有问题取决于你是如何使用它的.比如,你 ...
- ImagXpress中如何修改Alpha通道方法汇总
ImagXpress支持处理Alpha通道信息来管理图像的透明度,Alpha通道支持PNG ,TARGA和TIFF文件,同时还支持BMP和ICO文件.如果说保存的图像样式不支持Alpha通道,就将会丢 ...
- 在Win8下无法打开 hlp 帮助文件的问题
需要安装Win8针对该问题的补丁程序,并且修改注册表,详细的解决方案: http://support.microsoft.com/kb/917607/zh-cn#fixit4me
- linux cache and buffer【转】
转自:http://blog.csdn.net/turkeyzhou/article/details/6426738 版权声明:本文为博主原创文章,未经博主允许不得转载. Linux下对文件的访问和设 ...
- Tutorial: WPF User Control for AX2012
原作者: https://community.dynamics.com/ax/b/goshoom/archive/2011/10/06/tutorial-wpf-user-control-for-ax ...
- Dynamics AX 2012 R2 Business Connector Error
6.0: AxCryptoClient - New encryption key created 6.0: Unable to InitializeSession. 6.0: No built-in ...
- 第十一章 Android 内核驱动——Alarm
11.1 基本原理 Alarm 闹钟是 android 系统中在标准 RTC 驱动上开发的一个新的驱动,提供了一个定时器 用于把设备从睡眠状态唤醒,当然因为它是依赖 RTC 驱动的,所以它同时还可以 ...
- C类地址
C类地址第1字节.第2字节和第3个字节为网络地址,第4个字节为主机地址.另外第1个字节的前三位固定为110. C类地址范围:192.0.0.1到223.255.255.255.(第1个字节的二进制值前 ...
- YTU 3008: 链串的基本运算
3008: 链串的基本运算 时间限制: 1 Sec 内存限制: 128 MB 提交: 1 解决: 1 题目描述 编写一个程序,实现链串的各种基本运算,主函数已给出,请补充每一种方法. 1.建立串s ...