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的更多相关文章

  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 Round #378 (Div. 2) D - Kostya the Sculptor

    Kostya the Sculptor 这次cf打的又是心累啊,果然我太菜,真的该认真学习,不要随便的浪费时间啦 [题目链接]Kostya the Sculptor &题意: 给你n个长方体, ...

  3. 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 ...

  4. Codeforces378 D Kostya the Sculptor(贪心)(逻辑)

    Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

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

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

  6. 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 ...

  7. codeforces733D. Kostya the Sculptor 偏序cmp排序,数据结构hash,代码简化

    对于n==100.1,1,2或者1,2,2大量重复的形状相同的数据,cmp函数最后一项如果表达式带等于,整个程序就会崩溃 还没有仔细分析std::sort的调用过程,所以这里不是很懂..,mark以后 ...

  8. [CF733D]Kostya the Sculptor(贪心)

    题目链接:http://codeforces.com/contest/733/problem/D 题意:给n个长方体,允许最多两个拼在一起,拼接的面必须长宽相等.问想获得最大的内切圆的长方体序号是多少 ...

  9. CodeForces 733D Kostya the Sculptor

    排序.把每一个长方体拆成$6$个做,然后排序做即可. #pragma comment(linker, "/STACK:1024000000,1024000000") #includ ...

随机推荐

  1. [Usaco2008 Mar]Cow Travelling游荡的奶牛[简单DP]

    Description 奶牛们在被划分成N行M列(2 <= N <= 100; 2 <= M <= 100)的草地上游走,试图找到整块草地中最美味的牧草.Farmer John ...

  2. 企业架构研究总结(34)——TOGAF架构内容框架之架构制品(下)

    4.2.31 数据生命周期图(Data Lifecycle Diagram) 数据生命周期图是在业务流程的约束之下对业务数据在其整个生命周期(从概念阶段到最终退出)中对其进行管理的核心部分.数据从本质 ...

  3. Redis安装介绍

    Redis安装介绍 一.Linux版本及配置 1.  Linux版本:Red Hat Enterprise Linux 6虚拟机 2.  配置: 内存:1G:CPU:1核:硬盘:20G 二.Redis ...

  4. OJ题目JAVA与C运行效率对比

    [JAVA]深深跪了,OJ题目JAVA与C运行效率对比(附带清华北大OJ内存计算的对比) 看了园友的评论之后,我也好奇清橙OJ是怎么计算内存占用的.重新测试的情况附在原文后边. ----------- ...

  5. Chrome新的语言API,让您的浏览器说话

    还记得曾经那个能识别语音的API吗?当时一直在想,如果能让浏览器替我念出文字就好了.现在chrome的最新版本Version 33 中您只要按F12然后在console里面输入这段代码,您就能听到浏览 ...

  6. Arduino 3G shield using SoftwareSerial to control

    On the 3G shield, by default the power pin is on D8 and reset pin is on D9. Make it HIGH then it wor ...

  7. 使用Android网络编程实现简易聊天室

    在Java中我们可以利用socket编程实现聊天室,在Android中也一样,因为Android完全支持JDK本身的TCP.UDP网络通信API.我们可以使用ServerSocket.Socket来建 ...

  8. C++malloc,calloc,realloc,free函数

    在进行C/c++编程的时候,需要程序员对内存的了解比较清楚,经常需要操作的内存可分为下面几个类别:     1.堆栈区(stack):由编译器自动分配与释放,存放函数的参数值,局部变量,临时变量等等, ...

  9. 创建和使用SQL Server SSAS本地多维数据集

    Microsoft SQL Server SSAS的本地多维数据集(即Local Cube,也叫脱机多维数据集)和本地挖掘模型(Local Mining Models)允许在客户端机器上脱机执行离线分 ...

  10. java类静态域、块,非静态域、块,构造函数的初始化顺序

    原文:http://ini.iteye.com/blog/2007835 面试的时候,经常会遇到这样的考题:给你两个类的代码,它们之间是继承的关系,每个类里只有构造器方法和一些变量, 构造器里可能还有 ...