PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000123. Táo đỏ, táo xanh và táo không màu (Red and Green Apples)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Táo đỏ, táo xanh và táo không màu (Red and Green Apples)
Red and Green Apples
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
You must eat exactly red and green apples. There are red apples with values , green apples with values , and colorless apples with values , each of which can become either color. Maximize total tastiness.
Input
The first line has , then three lines with values , values , and values .
Output
Print the maximum total tastiness.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
1 1 2 2 2
5 2
4 1
10 3
Output
15
Explanation
Taking red and green yields . Replacing green by colorless (colored green) yields the optimum .