import time
def qsort(a):
if not a:
return
pivot = a[0]
left = []
right = []
for i in a[1:]:
if i < pivot:
left.append(i)
else:
right.append(i)
yield from qsort(left)
yield pivot
yield from qsort(right)
if __name__ == "__main__":
start = time.time()
sum = 0
data = [3,1,-5,7,-4,2,6,200,9,-2,4,3,0,-2] + [100] * 100000
for _, val in zip(range(20), qsort(data)):
sum += val * val
if sum > 50:
print('Sum = ', sum)
print(f'1000을 넘지 않은 최대 sum : {sum}')
print(f'경과 시간 : {int((time.time()-start)*1000)}ms')
# 경과 시간 : 130ms