赞
踩
- def storage(dic,p):
- if dic.get(slop) == None:
- dic[slop] = [(n,p)]
- else:
- lis = dic.get(slop)
- lis.append((n,p))
- dic[slop] = sorted(lis)
-
-
-
- def cout(dic):
- lis = list(dic.values())
- score = 0
- time = 0
- n = 0
- z = 1
- while n<len(lis):
- for i in lis[n]:
- if i[1]>1:
- z=1 if z!=0 else 2
- score+=i[1]
- else :
- z = 0
- score += i[1]
- time += z
- if lis[n][-1][1]==1: time+=1;z=1
- n+=1
- return (score,time)
-
- import math
- ldx = {}
- rdx = {}
- udy = {}
- ddy = {}
- N = int(input())
- while N>0:
- x, y, p = map(int, input().split())
- N-=1
- n = y
- if x!=0:
- a = math.gcd(x,y)
- slop = (x/a, y/a)
- if x>0:
- storage(rdx, p)
- else:
- storage(ldx, p)
- else:
- slop = (0, y)
- if y>0:
- storage(udy,p)
- else:
- storage(ddy, p)
-
- total = cout(ldx) + cout(rdx) + cout(udy) + cout(ddy)
-
- print(total[0]+total[2]+total[4]+total[6],end=' ')
- print(total[1]+total[3]+total[5]+total[7],end='')
-
-
-
-
-
-
-
最后运行还是有两个超时,按照我目前的水平可能无法优化。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。