-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathCut the sticks.py
42 lines (32 loc) · 945 Bytes
/
Cut the sticks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Problem Statement
You are given N sticks, where each stick is of positive integral length. A cut operation is performed on the sticks such
that all of them are reduced by the length of the smallest stick.
Suppose we have 6 sticks of length
"""
__author__ = 'Danyang'
class Solution(object):
def solve(self, cipher):
"""
main solution function
:param cipher: the cipher
"""
N, A = cipher
A.sort()
result = []
while A:
result.append(len(A))
A = map(lambda x: x - A[0], A)
A = filter(lambda x: x > 0, A)
return "\n".join(map(str, result))
if __name__ == "__main__":
import sys
f = open("1.in", "r")
# f = sys.stdin
solution = Solution()
N = int(f.readline().strip())
A = map(int, f.readline().strip().split(' '))
cipher = N, A
# solve
s = "%s\n" % (solution.solve(cipher))
print s,