-
Notifications
You must be signed in to change notification settings - Fork 0
/
BJ1744.py
82 lines (36 loc) · 1.03 KB
/
BJ1744.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
## 백준 1744번 수 묶기
k = int(input())
k_list = []
for i in range(k):
k_int = int(input())
k_list.append(k_int)
k_list = sorted(k_list , reverse = True)
##
x_list = []
y_list = []
k_sum = 0
for i in range(k):
if (k_list[i] > 1) :
x_list.append(k_list[i])
elif (k_list[i] == 1) :
k_sum += k_list[i]
elif(k_list[i] < 1) :
y_list.append(k_list[i])
y_list = sorted(y_list)
##
n = 2
x_list = [x_list[i * n:(i + 1) * n] for i in range((len(x_list) + n - 1) // n )]
for i in range(len(x_list)):
xx = 1
for x in range(len(x_list[i])):
xx *= x_list[i][x]
k_sum += xx
##
n = 2
y_list = [y_list[i * n:(i + 1) * n] for i in range((len(y_list) + n - 1) // n )]
for i in range(len(y_list)):
yy=1
for y in range(len(y_list[i])):
yy *= y_list[i][y]
k_sum += yy
print(k_sum)