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. Orchard学习

      Data Source=.\SQLEXPRESS;Initial Catalog=Arale;Integrated Security=True;

  2. ios学习笔记之UIControl解读

    UIControl,相信大家对其并不陌生吧,比如平常最常用的UIButton就是继承自UIControl的.按照惯例,还是先来看看为什么有UIControl这个类?什么时候用到它? 查下文档就可以看到 ...

  3. IOS学习之路七(通过xib自定义UITableViewCell)

    一.新建iOS Application工程,选择Single View Application,不要选中Use Storyboard.假设指定的是product name是:UITableViewCe ...

  4. 持续集成环境Gitlab-CI的官方安装过程解析

    持续集成环境是一个非常重要的工具,在分工合作的项目中有着举足轻重的作用.公司最近要用Gitlab,需要配套的持续集成环境.研究了官方的文档,感觉官方的文档不是很明了.各种修改过后终于成功了.为了大家安 ...

  5. c# winform 在一个窗体中使用另一个窗体中TextBox控件的值——解决办法

    [前提]一个winform应用程序项目中,窗体B,需要使用 窗体A 中一个TextBox控件的值,进行计算等操作. [解决方案] 1.在窗体A中定义:public static double a;// ...

  6. 简单的理解deflate算法

    简单的理解deflate算法 最近做压缩算法. 用到了deflate压缩算法,  找了很多资料,  这篇文章算是讲的比较易懂的, 这篇文章不长,但却浅显易懂, 基本上涵盖了我想要知道的所有要点. 翻译 ...

  7. POJ 3900 The Robbery

    大意:和背包的问题相似,第 i 个箱子有 i 颗钻石.钻石的重量,价值给出.然后再M的重量下背尽量多价值的钻石. 思路:直接暴搜然后剪枝.因为数据范围的原因无法用DP. #include <cs ...

  8. Speex Acoustic Echo Cancellation (AEC) 回声消除模块的使用

    背景:回声与啸叫的产生  http://blog.csdn.net/u011202336/article/details/9238397 参考资料:  http://www.speex.org/doc ...

  9. Ubuntu12.10 下搭建基于KVM-QEMU的虚拟机环境(八)

    Libvirt 是用c写的一个管理虚拟机及其资源(如网络.存储和外设等)的工具库,它不仅支持KVM/QEMU,它还支持xen,Vmware,OpenVZ和VirtualBox等其他HyperVisor ...

  10. C++ 头文件系列(queue)

    简介 这个头文件定义了两个跟队列有关的类----quque.priority_queue,分别实现的是队列 和 优先队列这两个概念. 但是与这两个类模版与其它类模版(vector.array等)最大的 ...