PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000274. Giảm nhỏ nhất giá trị lớn nhất của hai dãy (Minimize the Maximum of Two Arrays)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Giảm nhỏ nhất giá trị lớn nhất của hai dãy (Minimize the Maximum of Two Arrays)
Minimize the Maximum of Two Arrays
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given divisors and sizes , choose disjoint sets of positive integers of those sizes. No element of A is divisible by , and no element of B is divisible by . Minimize the greatest element of their union.
Input
One line contains .
Output
Print the optimal maximum value.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input 1
2 4 8 2
Output 1
15
Explanation
Choose the eight odd numbers through 15 for A and 2,6 for B. Any smaller bound has at most seven odd numbers.