-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1026.py
37 lines (23 loc) · 1.02 KB
/
1026.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
# [ 백준 ] 1026번: 보물
def solution() -> None:
N: int = int(input())
A: list[int] = list(map(int, input().split(" ")))
B: list[int] = list(map(int, input().split(" ")))
answer: int = 0
for A_num, B_num in zip(sorted(A), sorted(B, reverse=True)):
answer += (A_num * B_num)
print(answer)
def short_solution() -> None:
N: int = int(input())
A: list[int] = list(map(int, input().split(" ")))
B: list[int] = list(map(int, input().split(" ")))
print(sum([ A_num * B_num for A_num, B_num in zip(sorted(A), sorted(B, reverse=True)) ]))
if __name__ == "__main__":
import io
import unittest.mock
def test_example_case() -> None:
with unittest.mock.patch("builtins.input", side_effect=["5", "1 1 1 6 0", "2 7 8 3 1"]):
with unittest.mock.patch("sys.stdout", new_callable=io.StringIO) as test_stdout:
solution()
assert test_stdout.getvalue() == "18\n"
test_example_case()