Kostya the Sculptor
Kostya the Sculptor
题目链接:http://codeforces.com/problemset/problem/733/D
贪心
以次小边为第一关键字,最大边为第二关键字,最小边为第三关键字排序,每次只需要找次小边和最大边均相同,最小边最大的两项即可。
因为用Python遇到很多问题,切片操作a[i:j]是左闭右开区间[i,j)
代码如下:
n = int(input())
a = []
ans,u,v = 0,-1,-1
for i in range(n):
t = [int(x) for x in input().split()]
t.sort()
if ans < t[0]:
ans = t[0]
u = v = i
t.append(i)
a.append(t) from operator import itemgetter
a.sort(key=itemgetter(1,2,0),reverse=True) i = 0
while i+1 < n:
if a[i][1:3]==a[i+1][1:3]:
t = min(a[i][0]+a[i+1][0],a[i][1])
if ans < t:
ans = t
u = a[i][3]
v = a[i+1][3]
i += 1
while (i==0 or a[i][1:3]==a[i-1][1:3]) and i+1<len(a):
i += 1 if u == v:
print(1)
print(u+1)
else:
print(2)
print(u+1,v+1)
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 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 ...
- Codeforces378 D Kostya the Sculptor(贪心)(逻辑)
Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- 【25.47%】【codeforces 733D】Kostya the Sculptor
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 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 ...
- codeforces733D. Kostya the Sculptor 偏序cmp排序,数据结构hash,代码简化
对于n==100.1,1,2或者1,2,2大量重复的形状相同的数据,cmp函数最后一项如果表达式带等于,整个程序就会崩溃 还没有仔细分析std::sort的调用过程,所以这里不是很懂..,mark以后 ...
- [CF733D]Kostya the Sculptor(贪心)
题目链接:http://codeforces.com/contest/733/problem/D 题意:给n个长方体,允许最多两个拼在一起,拼接的面必须长宽相等.问想获得最大的内切圆的长方体序号是多少 ...
- CodeForces 733D Kostya the Sculptor
排序.把每一个长方体拆成$6$个做,然后排序做即可. #pragma comment(linker, "/STACK:1024000000,1024000000") #includ ...
随机推荐
- MVC TO LINQ
// // GET: /Home/ TestTryEntities Db = new TestTryEntities(); public ActionResult Index() { return V ...
- 多个AsynceTask无法同时运行的现象分析
关于这篇博客所提到的问题是在一段再简单不过的代码中意外出现的.当时我使用了两个不同'AsyncTask'帮助我执行两个需要在后台执行任务.并且这两个'AsyncTask'几乎是同时运行的.原本会正常运 ...
- linux serial 登录 cubieboard
折腾半天linux下的putty,最后搞得实在没办法,放弃putty改用minicom 1. 先安装minicom sudo apt-get install minicom 2.配置com minic ...
- Socket通信之Java学习(一)
最近从一篇博客中看到了Socket的介绍,是阿蜜果姐姐的博文:http://www.blogjava.net/amigoxie/archive/2007/02/11/99331.html,学习了下. ...
- Web API CSRF保护实现
Web API CSRF保护实现 这次自己实现了类似jQuery中ajax调用的方法,并且针对RESTFul进行了改造和集成,实现的A2D AJAX接口如下: $.ajax.RESTFulGetCol ...
- IOS touch event animation 转动的风车
最近开始学习IOS的开发,师兄给我提出一个需求:实现一个可拖动的转盘.师兄提示我说利用touch event和UIView animation.经过一两天的折腾边学边做,算是实现了基本功能.这里写写加 ...
- PHP使用DomDocument抓取HTML内容
有时候会有需要从一个HTML页面来分离出你需要的一些数据来进行处理. 当然自己分析文件肯定可以,但是比较快速且方便的是使用正则表达式或者DOM. 鉴于正则表达式我不熟悉,所以我打算使用DOM来完成. ...
- [置顶] NS2中对TCP数据包和ACK包的TCP Sink类的主要实现代码详尽剖析--吐血放送
NS2中对TCP数据包和ACK包的TCP Sink类的主要实现代码详尽剖析,限于个人水平,如有错误请留言指出! TcpSink类的recv()方法: void TcpSink::recv(Packet ...
- 链方法[C# 基础知识系列]专题三:如何用委托包装多个方法——委托链
最近研究链方法,稍微总结一下,以后继续补充: 弁言: 上一专题分析了下编译器是如何来翻译委托的,从中间语言的角度去看委托,希望可以帮助大家进一步的理解委托,然而之前的分析都是委托只是封装一个方法,那委 ...
- asp.net MVC 模拟实现与源码分析
前言 本文流程#1: 从一个空项目->模拟实现一个从/Home/Test形式的URL敲入->后台逻辑处理->传入后台model参数->调用razor引擎->前台展示 涉及 ...