-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogrammers_야근지수.py
More file actions
64 lines (51 loc) · 1.61 KB
/
programmers_야근지수.py
File metadata and controls
64 lines (51 loc) · 1.61 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import math
import copy
def solution(n, works):
# 야근 피로도 : 야근 시작 시점에서 남은 일의 작업량을 제곱하여 더한다
if len(works) ==0:
return 0
answer = 0
count_n = copy.copy(n)
works.sort(reverse=True)
for idx in range(len(works)+1):
if idx == len(works):
idx = idx//n
if works[idx] ==0:
pass
else:
works[idx] -= 1
count_n -=1
if count_n ==0:
answer = int(sum(list(map(lambda x: math.pow(x,2), works))))
return answer
# 큰 값부터 처리한 뒤 1번 줄여도 다른 값보다 크다면 다시 큰값부터
return answer
import math
import copy
def solution(n, works):
# 야근 피로도 : 야근 시작 시점에서 남은 일의 작업량을 제곱하여 더한다
if len(works) ==0:
return 0
answer = 0
count_n = copy.copy(n)
works.sort(reverse=True)
# works 가 없어진다면?
for idx in range(len(works)+1):
print('beftore works', works)
# print('idx ,{}'.format(idx),works)
# print('n:',n)
# print(works[idx])
if idx == len(works):
idx = idx//n
if works[idx] ==0:
pass
else:
works[idx] -= 1
count_n -=1
print('after works', works)
print(idx,count_n)
if count_n ==0:
answer = int(sum(list(map(lambda x: math.pow(x,2), works))))
return answer
# 큰 값부터 처리한 뒤 1번 줄여도 다른 값보다 크다면 다시 큰값부터
return answer