PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000110. Dọn bộ nhớ điện thoại (Cleaning the Phone)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Dọn bộ nhớ điện thoại (Cleaning the Phone)
Cleaning the Phone
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A phone has apps; app uses units of memory and uninstalling it loses convenience points. Uninstall a subset to free at least memory with minimum total lost points, or print -1 if impossible.
Input
Line 1 contains . Line 2 contains memory values . Line 3 contains costs .
Output
Print the minimum lost convenience or -1.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
5 7
5 3 2 1 4
2 1 1 2 1
Output
2
Explanation
Uninstall apps and to free memory units at convenience cost . No cost- choice can free memory units.