Kostya the Sculptor

Kostya the Sculptor

题目链接:http://codeforces.com/problemset/problem/733/D

贪心

以次小边为第一关键字,最大边为第二关键字,最小边为第三关键字排序,每次只需要找次小边和最大边均相同,最小边最大的两项即可。

因为用Python遇到很多问题,切片操作a[i:j]是左闭右开区间[i,j)

代码如下:

 1 n = int(input())
 2 a = []
 3 ans,u,v = 0,-1,-1
 4 for i in range(n):
 5     t = [int(x) for x in input().split()]
 6     t.sort()
 7     if ans < t[0]:
 8         ans = t[0]
 9         u = v = i
10     t.append(i)
11     a.append(t)
12
13 from operator import itemgetter
14 a.sort(key=itemgetter(1,2,0),reverse=True)
15
16 i = 0
17 while i+1 < n:
18     if a[i][1:3]==a[i+1][1:3]:
19         t = min(a[i][0]+a[i+1][0],a[i][1])
20         if ans < t:
21             ans = t
22             u = a[i][3]
23             v = a[i+1][3]
24     i += 1
25     while (i==0 or a[i][1:3]==a[i-1][1:3]) and i+1<len(a):
26         i += 1
27
28 if u == v:
29     print(1)
30     print(u+1)
31 else:
32     print(2)
33     print(u+1,v+1)
时间: 2024-11-10 01:15:02

Kostya the Sculptor的相关文章

CF733D Kostya the Sculptor[贪心 排序]

D. Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a frien

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. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from w

CodeForces 733D Kostya the Sculptor

排序.把每一个长方体拆成$6$个做,然后排序做即可. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #inc

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

对于n==100.1,1,2或者1,2,2大量重复的形状相同的数据,cmp函数最后一项如果表达式带等于,整个程序就会崩溃 还没有仔细分析std::sort的调用过程,所以这里不是很懂..,mark以后研究 因为题目让你挑一到两个平行六面体,然后去每个平行六面体长宽高的最小值,然后去求最小值中的最大值 我们很容易想到暴力的做法,如果两个平行六面体能够合并的话,那我们直接计算合并之后的最小值,因为我们知道此时 合并之后再求最小值,它是只增不减的 那么我们就要找到能合并某一个面的所有平行六面体的集合,

Optimal.Solutions.Sculptor.v3.6.150616 x64航天航空工业的图形

Optimal.Solutions.Sculptor.v3.6.150616 x64航天航空工业的图形一款用于航天航空工业的图形软件.用来完成不自然的标塔变形,自动优化,加上对CFD代码的分析工具, 将会更好的减小失误,节省时间 Gibbscam.2015.V11.0.9.0.Win64 虚拟加工系统 Golden.Software.Voxler.v4.0.476 FTI.Sculptured.Die.Face.3.1.Win64 Technical.Toolboxes.Pipeline.Too

REFORM-3PC.V7.0+FRNC-5PC.V8.0

Bentley.WaterGEMS.V8i.SS5.08.11.05.61 1CD 给水管网建模 REFORM-3PC.V7.0 FRNC-5PC.V8.0 通用加热炉工艺计算软件 REFORM-3PC 烃类蒸汽转化炉的炉膛截面评级程序Steam Hydrocarbon Reforming Simulation Program Chasm.Ventsim.Visual.Premium.v3.8.2.9.build.10.06.2014.Win32_64 1CD Bentley.AutoPIPE.

好几年才收集到的软件,分享给大家。。。

QQ:365543212Email:[email protected]请按Clrt+F查找,输入软件关键字查询(不要输入版本号),如果找不到,您可以咨询客服.................FD......................12D MODEL 7.0 规划设计232Analyzer v4.1 高级串口分析监测3D Home Architect Design Suite Deluxe 8.0 室内装潢3D Profiler Tools 11.2 For Archicad 113D R

java 对mongodb的操作

java 对mongodb的操作 1.1连单台mongodb Mongo mg = newMongo();//默认连本机127.0.0.1  端口为27017 Mongo mg = newMongo(ip);//可以指定ip 端口默认为27017 Mongo mg = newMongo(ip,port);//也可以指定ip及端口号 1.2连双台mongodb //ip为主机ip地址,port为端口号,dataBaseName相当于数据库名 DBAddress left = new DBAddre

coffeescript 1.8.0 documents

CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way. The golden rule