th0m45s5helby

Untitled

May 22nd, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. test=list(map(int,input().split()))
  2. for _ in range(test[0]):
  3.     n=test[1]
  4.     A=test[2:]
  5.     A=sorted(A)[::-1]
  6.     phase=0
  7.     print("Phase "+str(phase)+": "+str(len(A)))
  8.     while(len(A)>=2):
  9.         phase+=1
  10.         count=1
  11.         for i in reversed(range(len(A)-1)):
  12.             if A[i]==A[i+1]:
  13.                 count+=1
  14.             else:break
  15.         A=[k-A[-1] for k in A]
  16.         A=A[:len(A)-count]
  17.         A=sorted(A)[::-1]
  18.         print("Phase "+str(phase)+": "+str(len(A)))
Advertisement
Add Comment
Please, Sign In to add comment