CCF2019-09-Python题解

时间:2021-04-06 14:37:49   收藏:0   阅读:0

 

小明种树

试题编号: 201909-1
试题名称: 小明种苹果
时间限制: 2.0s
内存限制: 512.0MB

技术图片

 技术图片

题解:模拟一下,记录坏果数量和对应的果树的序号,排下序

3 3
73 -8 -6 -4
76 -5 -10 -8
80 -6 -15 0

 

 1 n,m=map(int, input().split())
 2 
 3 apple=[]
 4 summ_f=0
 5 for i in range(1,n+1):
 6     tmp=list(map(int, input().split()))
 7     lens=len(tmp)
 8     for j in range(1, lens):
 9         tmp[j]=abs(tmp[j])
10     bad=sum(tmp[1:])
11     tmp[0]-=bad
12     summ_f+=tmp[0]
13     apple.append([i,bad])
14 
15 apple.sort(key= lambda u:[-u[1],u[0]])
16 print(summ_f, end= )
17 print(apple[0][0],apple[0][1])

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!