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 ...
随机推荐
- Twitter算法
算法实践——Twitter算法面试题(积水问题)的线性时间解法 问题描述:在下图里我们有不同高度的挡板.这个图片由一个整数数组所代表,数组中每个数是墙的高度.下图可以表示为数组(2.5.1.2.3 ...
- Excel报表开发(主要讲Excel的导入和导出)
一.Excel数据导入 连接字符串Excel2003版: OleDbConnection conn = new OleDbConnection("provider=Microsoft.Jet ...
- C/C++基础知识总结——函数
1. 随机函数的使用 1.1 头文件: # include <cstdlib> 或 # include <stdlib.h> 1.2 用法 srand(int seed);// ...
- Build FFmpeg for iOS
FFmpeg Build Instructions MAC 10.8 or better Copy ffmpeg-2.0.tar.bz2 (https://ffmpeg.org/releases/ff ...
- 由ASP.NET所谓前台调用后台、后台调用前台想到HTTP
由ASP.NET所谓前台调用后台.后台调用前台想到HTTP 在由ASP.NET所谓前台调用后台.后台调用前台想到HTTP——理论篇中描述了一下ASP.NET新手的三个问题及相关的HTTP协议内容,在由 ...
- Oracle学习的一些建议(转)
核心提示:学习Oracle是一个漫长艰辛的过程.如果没有兴趣,只是被迫学习,那么是很难学好的.学习到一定程度的时候,要想进一步提高,就不得不接触很多Oracle之外的东西 学习Oracle是一个漫长艰 ...
- WP中一些耗时的东西
MediaPlayer.GameHasControl 耗时1.5ms MediaPlayer.State 耗时0.4ms 上面两个原本放在游戏的update中,后来注释掉发现其它的游戏逻辑只要0.2m ...
- Unable to start T-SQL Debugging. Could not connect to the computer ‘.’
Unable to start T-SQL Debugging. Could not connect to the computer ‘.’ 在Win7上面使用SSMS连接到SQL Server使用D ...
- 各浏览器的cookie的name个数/最大容量限制测试
测试代码 for(var ii = 0; ii< 5000;ii++){ if (!window.ia) window.ia=0; window.ia++; var s = 'a'+window ...
- [jstips]undefined和null的区别
undefined是指一个变量没有被声明,或者被声明了但是还没有被赋值 null是一个特定值(an assignment value ),代表"没有值"(no value) Jav ...