PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000044. Hai dãy và các phép đổi chỗ (Two Arrays And Swaps)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Hai dãy và các phép đổi chỗ (Two Arrays And Swaps)
Two Arrays And Swaps
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Two positive-integer arrays and have length . In one move, swap any and (possibly with different indices). Perform at most moves and maximize the sum of .
Input
Line 1: . Line 2: elements . Line 3: elements .
Output
Print the maximum possible sum of .
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Input
5 3
1 2 3 4 5
10 9 10 10 9
Output
39
Explanation
Replace the three smallest elements 1, 2, 3 with three 10s from . The resulting sum is .