-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3_2.py
91 lines (60 loc) · 1.22 KB
/
p3_2.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
83
84
85
86
87
88
89
90
91
import time
s_t = time.time()
# # main
# # my solution
n, m, k = map(int, input().split())
data = list(map(int, input().split()))
data.sort()
first = data[n-1]
second = data[n-2]
hap_max = k*(m//k) * first
hap_max += second * (m - m//k * k)
print(hap_max)
# n = 5
# m = 7
# k = 2
# hap = 0
# aa = [3,4,3,4,3]
# max_aa = max(aa)
# hap_max = k * (m//k) * max_aa
# aa.remove(max_aa)
# max_aa = max(aa)
# hap_max += max_aa * (m - m//k * k)
# print(hap_max)
### solution
# n, m, k = map(int,input().split())
# data = list(map(int, input().split()))
# data.sort()
# first = data[n-1]
# second = data[n-2]
# res = 0
# while True:
# for i in range(k):
# if m == 0:
# break
# res += first
# m -= 1
# if m == 0:
# break
# res += second
# m -= 1
# print(res)
# n, m, k = map(int, input().split())
# data = list(map(int, input().split()))
# data.sort()
# first = data[n-1]
# second = data[n-2]
# res = 0
# while True:
# for i in range(k):
# res += first
# m -= 1
# if m == 0:
# break
# res += second
# m -= 1
# if m == 0:
# break
# print(res)
e_t = time.time()
print('solving time is ', e_t - s_t, '(s)')