[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 ...
随机推荐
- Writable、WritableComparable和comparators
hadoop的序列化格式 hadoop自身的序列化存储格式就是实现了Writable接口的类,他只实现了前面两点,压缩和快速.但是不容易扩展,也不跨语言. 我们先来看下Writable接口,Writa ...
- CSS中的各个选择节点,都有样式最后一个无样式的快捷解决方法
2.1.3 多标签 多标签选择器一般和html上下文有关,它有以下集中分类 选择一个祖先的所有子孙节点,例如 div p{…} 选择一个父元素的所有直属节点,例如 div > p{…} 选择某一 ...
- 将edit ctrL弄的像个dos
case WM_CTLCOLOREDIT: { HWND hShellText = GetDlgItem(hDlg,IDC_TXT_SHELL); if (hShellText == (HWND)lP ...
- 【jQuery UI 1.8 The User Interface Library for jQuery】.学习笔记.8.Datepicker控件
默认datepicker的安装启用 探索它的配置选项 安装启用一个触发按钮 配置一个供选择的动画 dateFormat选项 简单的国际化 多月datepicker 日期范围选择 datepicker的 ...
- Codeforces 743D:Chloe and pleasant prizes(树形DP)
http://codeforces.com/problemset/problem/743/D 题意:求最大两个的不相交子树的点权和,如果没有两个不相交子树,那么输出Impossible. 思路:之前好 ...
- 杭电1020-Encoding
Problem Description Given a string containing only 'A' - 'Z', we could encode it using the following ...
- win7中sql2005 连接其它sql2005服务器,连不上
1.在管理工具-->高级安全 Windows 防火墙下配置下入站规则,将sql的端口加入里面,关闭防火墙并没有把这个给关闭掉 2 .Sql Server Browser 启用3.客户端协议 tc ...
- 单利 复利计算器程序1.0 2.0 3.0 [ 合 ] 之 WEB
对单复利计算器程序进行改进 更新为网页版的. 界面不太美观 请谅解 由于时间问题暂未完善好! 计算部分的主要源代码:
- Cookie机制(会话cookie和持久化cookie)在客户端保持HTTP状态信息的方案
1. Cookie只有一个name和一个value,不同于map;购物车设计的时候需要cookie,获取购物车的cookie id,以便于将物品多次放入购物车: 2.cookie获取了其地址,并且可以 ...
- Parencodings 分类: POJ 2015-06-28 22:00 7人阅读 评论(0) 收藏
Parencodings Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 22757 Accepted: 13337 De ...